OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 // This is a GPU-backend specific test | 8 // This is a GPU-backend specific test |
9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 | 10 |
11 #include "Test.h" | 11 #include "Test.h" |
12 | 12 |
13 // If we aren't inheriting these as #defines from elsewhere, | 13 // If we aren't inheriting these as #defines from elsewhere, |
14 // clang demands they be declared before we #include the template | 14 // clang demands they be declared before we #include the template |
15 // that relies on them. | 15 // that relies on them. |
16 static bool LT(const int& elem, int value) { | 16 static bool LT(const int& elem, int value) { |
17 return elem < value; | 17 return elem < value; |
18 } | 18 } |
19 static bool EQ(const int& elem, int value) { | 19 static bool EQ(const int& elem, int value) { |
20 return elem == value; | 20 return elem == value; |
21 } | 21 } |
22 | 22 |
23 #include "GrTBSearch.h" | 23 #include "GrTBSearch.h" |
24 | 24 |
25 DEF_TEST(GrTBSearchTest, reporter) { | 25 DEF_TEST(GrTBSearch, reporter) { |
26 const int array[] = { | 26 const int array[] = { |
27 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99 | 27 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99 |
28 }; | 28 }; |
29 | 29 |
30 for (int n = 0; n < static_cast<int>(SK_ARRAY_COUNT(array)); ++n) { | 30 for (int n = 0; n < static_cast<int>(SK_ARRAY_COUNT(array)); ++n) { |
31 for (int i = 0; i < n; i++) { | 31 for (int i = 0; i < n; i++) { |
32 int index = GrTBSearch<int, int>(array, n, array[i]); | 32 int index = GrTBSearch<int, int>(array, n, array[i]); |
33 REPORTER_ASSERT(reporter, index == (int) i); | 33 REPORTER_ASSERT(reporter, index == (int) i); |
34 index = GrTBSearch<int, int>(array, n, -array[i]); | 34 index = GrTBSearch<int, int>(array, n, -array[i]); |
35 REPORTER_ASSERT(reporter, index < 0); | 35 REPORTER_ASSERT(reporter, index < 0); |
36 } | 36 } |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 #endif | 40 #endif |
OLD | NEW |