diff options
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp')
-rw-r--r-- | Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp b/Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp index 7de23c9374e..3d94790fdc9 100644 --- a/Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp +++ b/Build/source/texk/dvisvgm/dvisvgm-src/tests/GraphicsPathParserTest.cpp @@ -2,7 +2,7 @@ ** GraphicsPathParserTest.cpp ** ** ** ** This file is part of dvisvgm -- a fast DVI to SVG converter ** -** Copyright (C) 2005-2023 Martin Gieseking <martin.gieseking@uos.de> ** +** Copyright (C) 2005-2024 Martin Gieseking <martin.gieseking@uos.de> ** ** ** ** This program is free software; you can redistribute it and/or ** ** modify it under the terms of the GNU General Public License as ** @@ -150,7 +150,20 @@ TEST(GraphicsPathParserTest, combined) { } -TEST(GraphicsPathParserTest, error) { +TEST(GraphicsPathParserTest, floats) { + GraphicsPathParser<double> parser; + auto path = parser.parse("M10 10.1L20.2 50.3Q 100 100 -10.1 -10.2 Z C 10e-1 2e2 30 40 50 60Z"); + ostringstream oss; + path.writeSVG(oss, false); + EXPECT_EQ(oss.str(), "M10 10.1L20.2 50.3Q100 100-10.1-10.2ZC1 200 30 40 50 60Z"); + oss.str(""); + path = parser.parse("m10 10.1l20.2 50.3q 100 100 -10.1 -10.2 z c 10 20 30 40 50 60 z"); + path.writeSVG(oss, false); + EXPECT_EQ(oss.str(), "M10 10.1L30.2 60.4Q130.2 160.4 20.1 50.2ZC20 30.1 40 50.1 60 70.1Z"); +} + + +TEST(GraphicsPathParserTest, error1) { GraphicsPathParser<int> parser; EXPECT_THROW(parser.parse("10 20"), GraphicsPathParserException); // missing command EXPECT_THROW(parser.parse("M10 "), GraphicsPathParserException); // missing y-coordinate @@ -161,3 +174,15 @@ TEST(GraphicsPathParserTest, error) { EXPECT_THROW(parser.parse("A 10 20 45 2 0 100 100"), GraphicsPathParserException); // invalid large-arc-flag EXPECT_THROW(parser.parse("A 10 20 45 0 5 100 100"), GraphicsPathParserException); // invalid sweep-flag } + + +TEST(GraphicsPathParserTest, error2) { + GraphicsPathParser<double> parser; + EXPECT_THROW(parser.parse("10 20"), GraphicsPathParserException); // missing command + EXPECT_THROW(parser.parse("M"), GraphicsPathParserException); // missing coordinates + EXPECT_THROW(parser.parse("M10.1 "), GraphicsPathParserException); // missing y-coordinate + EXPECT_THROW(parser.parse("M 10 20..5"), GraphicsPathParserException); // invalid double dots + EXPECT_THROW(parser.parse("M 10 20.5."), GraphicsPathParserException); // invalid trailing dot + EXPECT_THROW(parser.parse("M 10-20.1+"), GraphicsPathParserException); // invalid trailing plus + EXPECT_THROW(parser.parse("M.+10.20"), GraphicsPathParserException); // invalid plus after dot +} |