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

Side by Side Diff: tests/ValueTest.cpp

Issue 1585813004: SkValue: SkXfermode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-01-15 (Friday) 14:43:14 EST Created 4 years, 11 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
« src/core/SkValue.cpp ('K') | « src/effects/SkPixelXorXfermode.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 2016 Google Inc. 2 * Copyright 2016 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 "SkValue.h"
8 #include "Test.h" 9 #include "Test.h"
9 #include "SkValue.h" 10
11 static const SkValue::Type example_type = SkValue::Type(0x80000001);
12
13 enum { kExampleS32, kExampleF32, kExampleU32, kExampleObject};
14
15 #define EXAMPLES(FN) \
mtklein 2016/01/15 20:42:20 Let's expand this out?
16 FN(kExampleS32, S32, s32, -123) \
17 FN(kExampleF32, F32, f32, 0.5f) \
18 FN(kExampleU32, U32, u32, 1234) \
19
20 static SkValue make_example(skiatest::Reporter* r, int level = 4) {
21 auto value = SkValue::Object(example_type);
22 value.set(kExampleU32, SkValue::FromU32(1000));
23
24 #define FN(KEY, FNAME, MNAME, VALUE) \
25 value.set(KEY, SkValue::From##FNAME(VALUE));
26 EXAMPLES(FN)
27 #undef FN
28 if (level > 0) {
29 value.set(kExampleObject, make_example(r, 0));
30 value.set(kExampleObject, make_example(r, level - 1)); // replace
31 }
32 return value;
33 }
34
35 DEF_TEST(Value, r) {
36 SkValue val = make_example(r);
37 REPORTER_ASSERT(r, example_type == val.type());
38 val.set(4321, SkValue());
39 SkValue valCopy = val;
40 REPORTER_ASSERT(r, example_type == valCopy.type());
41 #define FN(KEY, FNAME, MNAME, VALUE) { \
42 const SkValue* v = val.get(KEY); \
43 REPORTER_ASSERT(r, v && VALUE == v->MNAME()); \
44 }
45 EXAMPLES(FN)
46 #undef FN
47 }
OLDNEW
« src/core/SkValue.cpp ('K') | « src/effects/SkPixelXorXfermode.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698