2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "SkParsePath.h"
11 static void test_to_from(skiatest::Reporter* reporter, const SkPath& path) {
13 SkParsePath::ToSVGString(path, &str);
16 bool success = SkParsePath::FromSVGString(str.c_str(), &path2);
17 REPORTER_ASSERT(reporter, success);
19 SkParsePath::ToSVGString(path2, &str2);
20 REPORTER_ASSERT(reporter, str == str2);
21 #if 0 // closed paths are not equal, the iter explicitly gives the closing
22 // edge, even if it is not in the path.
23 REPORTER_ASSERT(reporter, path == path2);
25 SkDebugf("str1=%s\nstr2=%s\n", str.c_str(), str2.c_str());
34 { "", { 0, 0, 0, 0 } },
35 { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } },
36 { "M-5.5,-0.5 Q 0 0 6,6.50",
41 DEF_TEST(ParsePath, reporter) {
42 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
44 bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path);
45 REPORTER_ASSERT(reporter, success);
46 const SkRect& expectedBounds = gRec[i].fBounds;
47 const SkRect& pathBounds = path.getBounds();
48 REPORTER_ASSERT(reporter, expectedBounds == pathBounds);
50 test_to_from(reporter, path);
54 r.set(0, 0, 10, 10.5f);
57 test_to_from(reporter, p);
59 test_to_from(reporter, p);
60 p.addRoundRect(r, 4, 4.5f);
61 test_to_from(reporter, p);