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

Side by Side Diff: tests/PathTest.cpp

Issue 732643002: Don't pass null to memcmp. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: simplify check Created 6 years, 1 month 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/core/SkPathRef.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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPaint.h" 9 #include "SkPaint.h"
10 #include "SkParse.h" 10 #include "SkParse.h"
(...skipping 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 a.lineTo(1, 2); 3428 a.lineTo(1, 2);
3429 REPORTER_ASSERT(reporter, a == b); 3429 REPORTER_ASSERT(reporter, a == b);
3430 } 3430 }
3431 3431
3432 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force, 3432 static void compare_dump(skiatest::Reporter* reporter, const SkPath& path, bool force,
3433 bool dumpAsHex, const char* str) { 3433 bool dumpAsHex, const char* str) {
3434 SkDynamicMemoryWStream wStream; 3434 SkDynamicMemoryWStream wStream;
3435 path.dump(&wStream, force, dumpAsHex); 3435 path.dump(&wStream, force, dumpAsHex);
3436 SkAutoDataUnref data(wStream.copyToData()); 3436 SkAutoDataUnref data(wStream.copyToData());
3437 REPORTER_ASSERT(reporter, data->size() == strlen(str)); 3437 REPORTER_ASSERT(reporter, data->size() == strlen(str));
3438 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str))); 3438 if (strlen(str) > 0) {
3439 REPORTER_ASSERT(reporter, !memcmp(data->data(), str, strlen(str)));
3440 } else {
3441 REPORTER_ASSERT(reporter, data->data() == NULL || !memcmp(data->data(), str, strlen(str)));
3442 }
3439 } 3443 }
3440 3444
3441 static void test_dump(skiatest::Reporter* reporter) { 3445 static void test_dump(skiatest::Reporter* reporter) {
3442 SkPath p; 3446 SkPath p;
3443 compare_dump(reporter, p, false, false, ""); 3447 compare_dump(reporter, p, false, false, "");
3444 compare_dump(reporter, p, true, false, ""); 3448 compare_dump(reporter, p, true, false, "");
3445 p.moveTo(1, 2); 3449 p.moveTo(1, 2);
3446 p.lineTo(3, 4); 3450 p.lineTo(3, 4);
3447 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n" 3451 compare_dump(reporter, p, false, false, "path.moveTo(1, 2);\n"
3448 "path.lineTo(3, 4);\n"); 3452 "path.lineTo(3, 4);\n");
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3623 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode); 3627 test_addEmptyPath(reporter, SkPath::kExtend_AddPathMode);
3624 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode); 3628 test_addEmptyPath(reporter, SkPath::kAppend_AddPathMode);
3625 test_conicTo_special_case(reporter); 3629 test_conicTo_special_case(reporter);
3626 test_get_point(reporter); 3630 test_get_point(reporter);
3627 test_contains(reporter); 3631 test_contains(reporter);
3628 PathTest_Private::TestPathTo(reporter); 3632 PathTest_Private::TestPathTo(reporter);
3629 PathRefTest_Private::TestPathRef(reporter); 3633 PathRefTest_Private::TestPathRef(reporter);
3630 test_dump(reporter); 3634 test_dump(reporter);
3631 test_path_crbugskia2820(reporter); 3635 test_path_crbugskia2820(reporter);
3632 } 3636 }
OLDNEW
« no previous file with comments | « src/core/SkPathRef.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698