OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "SkFunction.h" |
| 9 #include "Test.h" |
| 10 |
| 11 static void test_add_five(skiatest::Reporter* r, SkFunction<int(int)>&& f) { |
| 12 REPORTER_ASSERT(r, f(4) == 9); |
| 13 } |
| 14 |
| 15 static int add_five(int x) { return x + 5; } |
| 16 |
| 17 struct AddFive { |
| 18 int operator()(int x) { return x + 5; }; |
| 19 }; |
| 20 |
| 21 DEF_TEST(Function, r) { |
| 22 // We should be able to turn a static function, an explicit functor, or a la
mbda |
| 23 // all into an SkFunction equally well. |
| 24 test_add_five(r, SkFunction<int(int)>(&add_five)); |
| 25 test_add_five(r, SkFunction<int(int)>(AddFive())); |
| 26 test_add_five(r, SkFunction<int(int)>([](int x) { return x + 5; })); |
| 27 } |
OLD | NEW |