-
Notifications
You must be signed in to change notification settings - Fork 432
/
TestLine.java
72 lines (52 loc) · 2.19 KB
/
TestLine.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package technology.tabula;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.apache.pdfbox.pdmodel.font.PDType1Font;
import org.apache.pdfbox.pdmodel.font.Standard14Fonts;
import org.junit.Test;
public class TestLine {
@Test
public void testSetTextElements() {
Line line = new Line();
TextElement tElement = new TextElement(0, 0, 0, 0, new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 10, "test", 5);
TextChunk tChunk = new TextChunk(tElement);
List<TextChunk> tList = new ArrayList<>();
tList.add(tChunk);
line.setTextElements(tList);
assertEquals("test", line.getTextElements().get(0).getText());
}
@Test
public void testAddTextChunkIntTextChunk() {
Line line = new Line();
TextElement tElement = new TextElement(0, 0, 0, 0, new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 10, "test", 5);
TextChunk tChunk = new TextChunk(tElement);
line.addTextChunk(3, tChunk);
assertEquals("test", line.getTextElements().get(3).getText());
}
@Test
public void testLessThanAddTextChunkIntTextChunk() {
Line line = new Line();
TextElement tElement = new TextElement(0, 0, 0, 0, new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 10, "test", 5);
TextChunk tChunk = new TextChunk(tElement);
line.addTextChunk(0, tChunk);
line.addTextChunk(0, tChunk);
assertEquals("testtest", line.getTextElements().get(0).getText());
}
@Test(expected = IllegalArgumentException.class)
public void testErrorAddTextChunkIntTextChunk() {
Line line = new Line();
TextElement tElement = new TextElement(0, 0, 0, 0,new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 10, "test", 5);
TextChunk tChunk = new TextChunk(tElement);
line.addTextChunk(-1, tChunk);
}
@Test
public void testToString() {
Line line = new Line();
TextElement tElement = new TextElement(0, 0, 0, 0, new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 10, "test", 5);
TextChunk tChunk = new TextChunk(tElement);
line.addTextChunk(0, tChunk);
line.addTextChunk(0, tChunk);
assertEquals("technology.tabula.Line[x=0.0,y=0.0,w=0.0,h=0.0,bottom=0.000000,right=0.000000,chunks='testtest', ]", line.toString());
}
}