Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: tests/ParsePathTest.cpp

Issue 2339813003: Improved optional command handling in SkParsePath::FromSVGString() (Closed)
Patch Set: extra test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkParsePath.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ParsePathTest.cpp
diff --git a/tests/ParsePathTest.cpp b/tests/ParsePathTest.cpp
index fa239c2b3d44c79bce7f9d0c2e0cbf39a8d3c487..408f7805632a80ffb12bccc5f7d14687035975ad 100644
--- a/tests/ParsePathTest.cpp
+++ b/tests/ParsePathTest.cpp
@@ -88,3 +88,43 @@ DEF_TEST(ParsePathRandom, r) {
REPORTER_ASSERT(r, success);
}
}
+
+DEF_TEST(ParsePathOptionalCommand, r) {
+ struct {
+ const char* fStr;
+ int fVerbs;
+ int fPoints;
+ } gTests[] = {
+ { "", 0, 0 },
+
+ { "H100 200 ", 3, 3 },
+ { "H-100-200", 3, 3 },
+ { "H+100+200", 3, 3 },
+ { "H.10.20" , 3, 3 },
+ { "H-.10-.20", 3, 3 },
+ { "H+.10+.20", 3, 3 },
+
+ { "L100 100 200 200" , 3, 3 },
+ { "L-100-100-200-200", 3, 3 },
+ { "L+100+100+200+200", 3, 3 },
+ { "L.10.10.20.20" , 3, 3 },
+ { "L-.10-.10-.20-.20", 3, 3 },
+ { "L+.10+.10+.20+.20", 3, 3 },
+
+ { "C100 100 200 200 300 300 400 400 500 500 600 600" , 3, 7 },
+ { "C100-100-200-200-300-300-400-400-500-500-600-600" , 3, 7 },
+ { "C100+100+200+200+300+300+400+400+500+500+600+600" , 3, 7 },
+ { "C.10.10.20.20.30.30.40.40.50.50.60.60" , 3, 7 },
+ { "C-.10-.10-.20-.20-.30-.30-.40-.40-.50-.50-.60-.60", 3, 7 },
+ { "C+.10+.10+.20+.20+.30+.30+.40+.40+.50+.50+.60+.60", 3, 7 },
+
+ { "c-1.49.71-2.12 2.5-1.4 4 .71 1.49 2.5 2.12 4 1.4z", 4, 7 },
+ };
+
+ SkPath path;
+ for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) {
+ REPORTER_ASSERT(r, SkParsePath::FromSVGString(gTests[i].fStr, &path));
+ REPORTER_ASSERT(r, path.countVerbs() == gTests[i].fVerbs);
+ REPORTER_ASSERT(r, path.countPoints() == gTests[i].fPoints);
+ }
+}
« no previous file with comments | « src/utils/SkParsePath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698