blob: d05780778b48fbbdcf0f8237a194b7433a35826f [file] [log] [blame]
tfarina@chromium.orgbbff2082014-01-31 21:48:52 +00001/*
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.
16static bool LT(const int& elem, int value) {
17 return elem < value;
18}
19static bool EQ(const int& elem, int value) {
20 return elem == value;
21}
22
23#include "GrTBSearch.h"
24
tfarina9ea53f92014-06-24 06:50:39 -070025DEF_TEST(GrTBSearch, reporter) {
tfarina@chromium.orgbbff2082014-01-31 21:48:52 +000026 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