OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkFunction.h" | 8 #include "SkFunction.h" |
9 #include "Test.h" | 9 #include "Test.h" |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // AddFive and the lambda above are both small enough to test small-object o
ptimization. | 38 // AddFive and the lambda above are both small enough to test small-object o
ptimization. |
39 // Now test a lambda that's much too large for the small-object optimization
. | 39 // Now test a lambda that's much too large for the small-object optimization
. |
40 int a = 1, b = 1, c = 1, d = 1, e = 1; | 40 int a = 1, b = 1, c = 1, d = 1, e = 1; |
41 test_add_five(r, [&](int x) { return x + a + b + c + d + e; }); | 41 test_add_five(r, [&](int x) { return x + a + b + c + d + e; }); |
42 | 42 |
43 // Makes sure we forward the functor when constructing SkFunction. | 43 // Makes sure we forward the functor when constructing SkFunction. |
44 test_add_five(r, MoveOnlyAdd5()); | 44 test_add_five(r, MoveOnlyAdd5()); |
45 | 45 |
46 // Makes sure we forward arguments when calling SkFunction. | 46 // Makes sure we forward arguments when calling SkFunction. |
47 REPORTER_ASSERT(r, [](int x, MoveOnlyAdd5&& f, int y) { | 47 SkFunction<int(int, MoveOnlyAdd5&&, int)> f([](int x, MoveOnlyAdd5&& addFive
, int y) { |
48 return x * f(y); | 48 return x * addFive(y); |
49 }(2, MoveOnlyAdd5(), 4) == 18); | 49 }); |
| 50 REPORTER_ASSERT(r, f(2, MoveOnlyAdd5(), 4) == 18); |
50 } | 51 } |
OLD | NEW |