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

Side by Side Diff: tests/RecordTestUtils.h

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 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 | « tests/RTreeTest.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #ifndef RecordTestUtils_DEFINED 1 #ifndef RecordTestUtils_DEFINED
2 #define RecordTestUtils_DEFINED 2 #define RecordTestUtils_DEFINED
3 3
4 #include "SkRecord.h" 4 #include "SkRecord.h"
5 #include "SkRecords.h" 5 #include "SkRecords.h"
6 6
7 // If the command we're reading is a U, set ptr to it, otherwise set it to NULL. 7 // If the command we're reading is a U, set ptr to it, otherwise set it to NULL.
8 template <typename U> 8 template <typename U>
9 struct ReadAs { 9 struct ReadAs {
10 ReadAs() : ptr(NULL), type(SkRecords::Type(~0)) {} 10 ReadAs() : ptr(NULL), type(SkRecords::Type(~0)) {}
11 11
12 const U* ptr; 12 const U* ptr;
13 SkRecords::Type type; 13 SkRecords::Type type;
14 14
15 void operator()(const U& r) { ptr = &r; type = U::kType; } 15 void operator()(const U& r) { ptr = &r; type = U::kType; }
16 16
17 template <typename T> 17 template <typename T>
18 void operator()(const T&) { type = U::kType; } 18 void operator()(const T&) { type = U::kType; }
19 }; 19 };
20 20
21 // Assert that the ith command in record is of type T, and return it. 21 // Assert that the ith command in record is of type T, and return it.
22 template <typename T> 22 template <typename T>
23 static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsig ned index) { 23 static const T* assert_type(skiatest::Reporter* r, const SkRecord& record, unsig ned index) {
24 ReadAs<T> reader; 24 ReadAs<T> reader;
25 record.visit<void>(index, reader); 25 record.visit<void>(index, reader);
26 REPORTER_ASSERT(r, T::kType == reader.type); 26 REPORTER_ASSERT(r, T::kType == reader.type);
27 REPORTER_ASSERT(r, NULL != reader.ptr); 27 REPORTER_ASSERT(r, SkToBool(reader.ptr));
28 return reader.ptr; 28 return reader.ptr;
29 } 29 }
30 30
31 #endif//RecordTestUtils_DEFINED 31 #endif//RecordTestUtils_DEFINED
OLDNEW
« no previous file with comments | « tests/RTreeTest.cpp ('k') | tests/ResourceCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698