diff options
-rw-r--r-- | gyp/tests.gyp | 3 | ||||
-rw-r--r-- | src/gpu/GrTBSearch.h | 5 | ||||
-rw-r--r-- | tests/GrBinHashKeyTest.cpp (renamed from tests/GrUnitTests.cpp) | 36 | ||||
-rw-r--r-- | tests/GrTBSearchTest.cpp | 40 |
4 files changed, 47 insertions, 37 deletions
diff --git a/gyp/tests.gyp b/gyp/tests.gyp index 42ddebe219..15692aeee3 100644 --- a/gyp/tests.gyp +++ b/gyp/tests.gyp @@ -81,12 +81,13 @@ '../tests/GpuBitmapCopyTest.cpp', '../tests/GpuColorFilterTest.cpp', '../tests/GpuDrawPathTest.cpp', + '../tests/GrBinHashKeyTest.cpp', '../tests/GrContextFactoryTest.cpp', '../tests/GrDrawTargetTest.cpp', '../tests/GrMemoryPoolTest.cpp', '../tests/GrRedBlackTreeTest.cpp', '../tests/GrSurfaceTest.cpp', - '../tests/GrUnitTests.cpp', + '../tests/GrTBSearchTest.cpp', '../tests/GradientTest.cpp', '../tests/HashCacheTest.cpp', '../tests/ImageCacheTest.cpp', diff --git a/src/gpu/GrTBSearch.h b/src/gpu/GrTBSearch.h index 08b0b85f35..01e97440a6 100644 --- a/src/gpu/GrTBSearch.h +++ b/src/gpu/GrTBSearch.h @@ -1,4 +1,3 @@ - /* * Copyright 2010 Google Inc. * @@ -6,11 +5,11 @@ * found in the LICENSE file. */ - - #ifndef GrTBSearch_DEFINED #define GrTBSearch_DEFINED +#include "SkTypes.h" + template <typename ELEM, typename KEY> int GrTBSearch(const ELEM array[], int count, KEY target) { SkASSERT(count >= 0); diff --git a/tests/GrUnitTests.cpp b/tests/GrBinHashKeyTest.cpp index 4c605d6051..96b851f8b0 100644 --- a/tests/GrUnitTests.cpp +++ b/tests/GrBinHashKeyTest.cpp @@ -1,47 +1,18 @@ - /* * Copyright 2010 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ -#include "Test.h" // This is a GPU-backend specific test #if SK_SUPPORT_GPU -#include "GrBinHashKey.h" -#include "GrDrawTarget.h" -#include "GrRedBlackTree.h" -#include "SkMatrix.h" - -// If we aren't inheriting these as #defines from elsewhere, -// clang demands they be declared before we #include the template -// that relies on them. -static bool LT(const int& elem, int value) { - return elem < value; -} -static bool EQ(const int& elem, int value) { - return elem == value; -} -#include "GrTBSearch.h" +#include "GrBinHashKey.h" -DEF_TEST(GrUnitTests_bsearch, reporter) { - const int array[] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99 - }; - - for (int n = 0; n < static_cast<int>(GR_ARRAY_COUNT(array)); ++n) { - for (int i = 0; i < n; i++) { - int index = GrTBSearch<int, int>(array, n, array[i]); - REPORTER_ASSERT(reporter, index == (int) i); - index = GrTBSearch<int, int>(array, n, -array[i]); - REPORTER_ASSERT(reporter, index < 0); - } - } -} +#include "Test.h" -DEF_TEST(GrUnitTests_binHashKey, reporter) { +DEF_TEST(GrBinHashKeyTest, reporter) { const char* testStringA_ = "abcdABCD"; const char* testStringB_ = "abcdBBCD"; const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_); @@ -67,5 +38,4 @@ DEF_TEST(GrUnitTests_binHashKey, reporter) { REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); } - #endif diff --git a/tests/GrTBSearchTest.cpp b/tests/GrTBSearchTest.cpp new file mode 100644 index 0000000000..70a24d3197 --- /dev/null +++ b/tests/GrTBSearchTest.cpp @@ -0,0 +1,40 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +// This is a GPU-backend specific test +#if SK_SUPPORT_GPU + +#include "Test.h" + +// If we aren't inheriting these as #defines from elsewhere, +// clang demands they be declared before we #include the template +// that relies on them. +static bool LT(const int& elem, int value) { + return elem < value; +} +static bool EQ(const int& elem, int value) { + return elem == value; +} + +#include "GrTBSearch.h" + +DEF_TEST(GrTBSearchTest, reporter) { + const int array[] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99 + }; + + for (int n = 0; n < static_cast<int>(SK_ARRAY_COUNT(array)); ++n) { + for (int i = 0; i < n; i++) { + int index = GrTBSearch<int, int>(array, n, array[i]); + REPORTER_ASSERT(reporter, index == (int) i); + index = GrTBSearch<int, int>(array, n, -array[i]); + REPORTER_ASSERT(reporter, index < 0); + } + } +} + +#endif |