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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/utils/SkParsePath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkParsePath.h" 8 #include "SkParsePath.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 SkPath path, path2; 81 SkPath path, path2;
82 SkString spec; 82 SkString spec;
83 uint32_t count = rand.nextRangeU(0, 10); 83 uint32_t count = rand.nextRangeU(0, 10);
84 for (uint32_t i = 0; i < count; ++i) { 84 for (uint32_t i = 0; i < count; ++i) {
85 spec.append(MakeRandomParsePathPiece(&rand)); 85 spec.append(MakeRandomParsePathPiece(&rand));
86 } 86 }
87 bool success = SkParsePath::FromSVGString(spec.c_str(), &path); 87 bool success = SkParsePath::FromSVGString(spec.c_str(), &path);
88 REPORTER_ASSERT(r, success); 88 REPORTER_ASSERT(r, success);
89 } 89 }
90 } 90 }
91
92 DEF_TEST(ParsePathOptionalCommand, r) {
93 struct {
94 const char* fStr;
95 int fVerbs;
96 int fPoints;
97 } gTests[] = {
98 { "", 0, 0 },
99
100 { "H100 200 ", 3, 3 },
101 { "H-100-200", 3, 3 },
102 { "H+100+200", 3, 3 },
103 { "H.10.20" , 3, 3 },
104 { "H-.10-.20", 3, 3 },
105 { "H+.10+.20", 3, 3 },
106
107 { "L100 100 200 200" , 3, 3 },
108 { "L-100-100-200-200", 3, 3 },
109 { "L+100+100+200+200", 3, 3 },
110 { "L.10.10.20.20" , 3, 3 },
111 { "L-.10-.10-.20-.20", 3, 3 },
112 { "L+.10+.10+.20+.20", 3, 3 },
113
114 { "C100 100 200 200 300 300 400 400 500 500 600 600" , 3, 7 },
115 { "C100-100-200-200-300-300-400-400-500-500-600-600" , 3, 7 },
116 { "C100+100+200+200+300+300+400+400+500+500+600+600" , 3, 7 },
117 { "C.10.10.20.20.30.30.40.40.50.50.60.60" , 3, 7 },
118 { "C-.10-.10-.20-.20-.30-.30-.40-.40-.50-.50-.60-.60", 3, 7 },
119 { "C+.10+.10+.20+.20+.30+.30+.40+.40+.50+.50+.60+.60", 3, 7 },
120
121 { "c-1.49.71-2.12 2.5-1.4 4 .71 1.49 2.5 2.12 4 1.4z", 4, 7 },
122 };
123
124 SkPath path;
125 for (size_t i = 0; i < SK_ARRAY_COUNT(gTests); ++i) {
126 REPORTER_ASSERT(r, SkParsePath::FromSVGString(gTests[i].fStr, &path));
127 REPORTER_ASSERT(r, path.countVerbs() == gTests[i].fVerbs);
128 REPORTER_ASSERT(r, path.countPoints() == gTests[i].fPoints);
129 }
130 }
OLDNEW
« 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