From 4ff80b2ad0c7a86ec2ff3297027a51317961e49a Mon Sep 17 00:00:00 2001 From: James Ball Date: Mon, 26 Oct 2020 17:34:45 +0000 Subject: [PATCH] Pass lineToGeneratesALineShape --- src/shapes/Line.java | 8 ++++++++ src/shapes/Vector2.java | 8 ++++++++ test/SvgParserTest.java | 9 +++++++-- test/images/line-to.svg | 5 +++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 test/images/line-to.svg diff --git a/src/shapes/Line.java b/src/shapes/Line.java index 91d5f82..b090b83 100644 --- a/src/shapes/Line.java +++ b/src/shapes/Line.java @@ -114,4 +114,12 @@ public final class Line extends Shape { return false; } } + + @Override + public String toString() { + return "Line{" + + "a=" + a + + ", b=" + b + + '}'; + } } diff --git a/src/shapes/Vector2.java b/src/shapes/Vector2.java index 75749ce..324ce93 100644 --- a/src/shapes/Vector2.java +++ b/src/shapes/Vector2.java @@ -114,4 +114,12 @@ public final class Vector2 extends Shape { return (double) Math.round(value) / factor; } + + @Override + public String toString() { + return "Vector2{" + + "x=" + x + + ", y=" + y + + '}'; + } } diff --git a/test/SvgParserTest.java b/test/SvgParserTest.java index 515b070..410fd1a 100644 --- a/test/SvgParserTest.java +++ b/test/SvgParserTest.java @@ -13,8 +13,13 @@ import shapes.Vector2; public class SvgParserTest { @Test - public void lineToGeneratesALineShape() { - + public void lineToGeneratesALineShape() + throws ParserConfigurationException, SAXException, IOException { + SvgParser svgParser = new SvgParser("test/images/line-to.svg"); + List shapes = svgParser.getShapes(); + assertEquals(shapes.get(0), new Line(new Vector2(0.5, 0.5), new Vector2(0.75, 1))); + assertEquals(shapes.get(1), new Line(new Vector2(0.75, 1), new Vector2(0, 0))); + assertEquals(shapes.get(2), new Line(new Vector2(0, 0), new Vector2(0.5, 0.5))); } @Test diff --git a/test/images/line-to.svg b/test/images/line-to.svg new file mode 100644 index 0000000..ec08c84 --- /dev/null +++ b/test/images/line-to.svg @@ -0,0 +1,5 @@ + \ No newline at end of file