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