forked from tabulapdf/tabula-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestUtils.java
More file actions
66 lines (49 loc) · 1.88 KB
/
TestUtils.java
File metadata and controls
66 lines (49 loc) · 1.88 KB
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
package org.nerdpower.tabula;
import static org.junit.Assert.*;
import java.awt.geom.Point2D;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.cli.ParseException;
import org.junit.Test;
public class TestUtils {
public static final Ruling[] RULINGS = {
new Ruling(new Point2D.Float(0, 0), new Point2D.Float(1,1)),
new Ruling(new Point2D.Float(2, 2), new Point2D.Float(3,3))
};
public static final Rectangle[] RECTANGLES = {
new Rectangle(),
new Rectangle(0, 0, 2, 4)
};
@Test
public void testBoundsOfTwoRulings() {
Rectangle r = Utils.bounds(Arrays.asList(RULINGS));
assertEquals(0, r.getMinX(), 0);
assertEquals(0, r.getMinY(), 0);
assertEquals(3, r.getWidth(), 0);
assertEquals(3, r.getHeight(), 0);
}
@Test
public void testBoundsOfOneEmptyRectangleAndAnotherNonEmpty() {
Rectangle r = Utils.bounds(Arrays.asList(RECTANGLES));
assertEquals(r, RECTANGLES[1]);
}
@Test
public void testParsePagesOption() throws ParseException {
List<Integer> rv = Utils.parsePagesOption("1");
assertArrayEquals(new Integer[] { 1 }, rv.toArray());
rv = Utils.parsePagesOption("1-4");
assertArrayEquals(new Integer[] { 1,2,3,4 }, rv.toArray());
rv = Utils.parsePagesOption("1-4,20-24");
assertArrayEquals(new Integer[] { 1,2,3,4,20,21,22,23,24 }, rv.toArray());
rv = Utils.parsePagesOption("all");
assertNull(rv);
}
@Test(expected=ParseException.class)
public void testExceptionInParsePages() throws ParseException {
Utils.parsePagesOption("1-4,24-22");
}
@Test(expected=ParseException.class)
public void testAnotherExceptionInParsePages() throws ParseException {
Utils.parsePagesOption("quuxor");
}
}