#490: Fix for "incomplete" paths with implicit line back to start.

This commit is contained in:
Harald Kuhr
2020-01-17 16:44:42 +01:00
parent d2b58ed20e
commit 420f78be88
2 changed files with 49 additions and 6 deletions
@@ -44,8 +44,7 @@ import java.util.Arrays;
import static com.twelvemonkeys.imageio.path.AdobePathSegment.*;
import static com.twelvemonkeys.imageio.path.PathsTest.assertPathEquals;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* AdobePathWriterTest.
@@ -93,6 +92,46 @@ public class AdobePathWriterTest {
new AdobePathWriter(path);
}
@Test
public void testCreateClosed() {
GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD);
path.moveTo(.5, .5);
path.lineTo(1, .5);
path.curveTo(1, 1, 1, 1, .5, 1);
path.closePath();
new AdobePathWriter(path).writePath();
fail("Test that we have 4 segments");
}
@Test
public void testCreateImplicitClosed() {
GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD);
path.moveTo(.5, .5);
path.lineTo(1, .5);
path.curveTo(1, 1, 1, 1, .5, 1);
path.lineTo(.5, .5);
new AdobePathWriter(path).writePath(); // TODO: Should we allow this?
fail("Test that we have 4 segments, and that it is equal to the one above");
}
@Test
public void testCreateDoubleClosed() {
GeneralPath path = new GeneralPath(Path2D.WIND_EVEN_ODD);
path.moveTo(.5, .5);
path.lineTo(1, .5);
path.curveTo(1, 1, 1, 1, .5, 1);
path.lineTo(.5, .5);
path.closePath();
new AdobePathWriter(path).writePath();
fail("Test that we have 4 segments, and that it is equal to the one above");
}
@Test
public void testWriteToStream() throws IOException {
Path2D path = new GeneralPath(Path2D.WIND_EVEN_ODD);
@@ -168,7 +207,7 @@ public class AdobePathWriterTest {
AdobePathWriter pathCreator = new AdobePathWriter(path);
byte[] bytes = pathCreator.writePath();
System.err.println(Arrays.toString(bytes));
// System.err.println(Arrays.toString(bytes));
assertEquals(12 * 26, bytes.length);