View Javadoc
1   package org.csveed.report;
2   
3   import static org.junit.jupiter.api.Assertions.assertEquals;
4   
5   import java.util.List;
6   
7   import org.junit.jupiter.api.Test;
8   
9   public class RowReportTest {
10  
11      @Test
12      public void relevantBlockAtStart() {
13          RowReport report = new RowReport("0123456789", 0, 4);
14          assertEquals(2, report.tokenize().size());
15          assertEquals("0123", report.tokenize().get(0).getToken());
16          assertEquals("456789", report.tokenize().get(1).getToken());
17      }
18  
19      @Test
20      public void relevantBlockInMiddle() {
21          RowReport report = new RowReport("0123456789", 3, 6);
22          assertEquals(3, report.tokenize().size());
23          assertEquals("012", report.tokenize().get(0).getToken());
24          assertEquals("345", report.tokenize().get(1).getToken());
25          assertEquals("6789", report.tokenize().get(2).getToken());
26      }
27  
28      @Test
29      public void relevantBlockAtEnd() {
30          RowReport report = new RowReport("0123456789", 7, 10);
31          assertEquals(2, report.tokenize().size());
32          assertEquals("0123456", report.tokenize().get(0).getToken());
33          assertEquals("789", report.tokenize().get(1).getToken());
34      }
35  
36      @Test
37      public void tooSmallToNotice() {
38          RowReport report = new RowReport("0123456789", 7, 7);
39          assertEquals(3, report.tokenize().size());
40          assertEquals("0123456", report.tokenize().get(0).getToken());
41          assertEquals("7", report.tokenize().get(1).getToken());
42          assertEquals("89", report.tokenize().get(2).getToken());
43      }
44  
45      @Test
46      public void onlyAtTheEnd() {
47          RowReport report = new RowReport("0123456789", 10, 10);
48          List<String> lines = report.getPrintableLines();
49          assertEquals("          ^", lines.get(1));
50      }
51  
52  }