-
-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathPShapeSVGTest.java
More file actions
56 lines (49 loc) · 1.8 KB
/
PShapeSVGTest.java
File metadata and controls
56 lines (49 loc) · 1.8 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
package processing.core;
import org.junit.Assert;
import org.junit.Test;
import processing.data.XML;
import processing.core.PImage;
import java.awt.*;
public class PShapeSVGTest {
private static final String[] TEST_CONTENT = {
"<svg><g><path d=\"L 0,3.1.4.1\"/></g></svg>",
"<svg><g><path d=\"m-13.6 4.69-1.35 0.78h-0.00034l1.33 2.27 1.33-0.77a6.48 6.47 43.14 0 1-1.31-2.27z\"/></g></svg>"
};
private static final int[] TEST_NVERTEX = {2, 8};
private static final String TEST_EXPONENT =
"<svg><g><path d=\"m-1.36E1 469e-2-1.35 0.78h-3.4e-4l1.33 2.27 1.33-0.77a6.48 6.47 43.14 0 1-1.31-2.27z\"/></g></svg>";
@Test
public void testDecimals() {
try {
for (int i = 0; i < TEST_CONTENT.length; ++i) {
XML xml = XML.parse(TEST_CONTENT[i]);
PShapeSVG shape = new PShapeSVG(xml);
PShape[] children = shape.getChildren();
Assert.assertEquals(1, children.length);
PShape[] grandchildren = children[0].getChildren();
Assert.assertEquals(1, grandchildren.length);
Assert.assertEquals(0, grandchildren[0].getChildCount());
Assert.assertEquals(TEST_NVERTEX[i], grandchildren[0].getVertexCount());
}
}
catch (Exception e) {
Assert.fail("Encountered exception " + e);
}
}
@Test
public void testExponent() {
try {
XML xml = XML.parse(TEST_EXPONENT);
PShapeSVG shape = new PShapeSVG(xml);
PShape[] children = shape.getChildren();
Assert.assertEquals(1, children.length);
PShape[] grandchildren = children[0].getChildren();
Assert.assertEquals(1, grandchildren.length);
Assert.assertEquals(0, grandchildren[0].getChildCount());
Assert.assertEquals(8, grandchildren[0].getVertexCount());
}
catch (Exception e) {
Assert.fail("Encountered exception " + e);
}
}
}