1
2
3
4
5
6
7
8
9
10
11 package org.csveed.report;
12
13 import static org.junit.jupiter.api.Assertions.assertEquals;
14
15 import java.util.List;
16
17 import org.junit.jupiter.api.Test;
18
19
20
21
22 class RowReportTest {
23
24
25
26
27 @Test
28 void relevantBlockAtStart() {
29 RowReport report = new RowReport("0123456789", 0, 4);
30 assertEquals(2, report.tokenize().size());
31 assertEquals("0123", report.tokenize().get(0).getToken());
32 assertEquals("456789", report.tokenize().get(1).getToken());
33 }
34
35
36
37
38 @Test
39 void relevantBlockInMiddle() {
40 RowReport report = new RowReport("0123456789", 3, 6);
41 assertEquals(3, report.tokenize().size());
42 assertEquals("012", report.tokenize().get(0).getToken());
43 assertEquals("345", report.tokenize().get(1).getToken());
44 assertEquals("6789", report.tokenize().get(2).getToken());
45 }
46
47
48
49
50 @Test
51 void relevantBlockAtEnd() {
52 RowReport report = new RowReport("0123456789", 7, 10);
53 assertEquals(2, report.tokenize().size());
54 assertEquals("0123456", report.tokenize().get(0).getToken());
55 assertEquals("789", report.tokenize().get(1).getToken());
56 }
57
58
59
60
61 @Test
62 void tooSmallToNotice() {
63 RowReport report = new RowReport("0123456789", 7, 7);
64 assertEquals(3, report.tokenize().size());
65 assertEquals("0123456", report.tokenize().get(0).getToken());
66 assertEquals("7", report.tokenize().get(1).getToken());
67 assertEquals("89", report.tokenize().get(2).getToken());
68 }
69
70
71
72
73 @Test
74 void onlyAtTheEnd() {
75 RowReport report = new RowReport("0123456789", 10, 10);
76 List<String> lines = report.getPrintableLines();
77 assertEquals(" ^", lines.get(1));
78 }
79
80 }