reed@android.com | 5e5adfd | 2009-03-07 03:39:23 +0000 | [diff] [blame^] | 1 | #include "Test.h" |
| 2 | #include "SkRandom.h" |
| 3 | #include "SkTSearch.h" |
| 4 | |
| 5 | extern "C" { |
| 6 | int compare_int(const void* a, const void* b) { |
| 7 | return *(const int*)a - *(const int*)b; |
| 8 | } |
| 9 | } |
| 10 | |
| 11 | static void TestSort(skiatest::Reporter* reporter) { |
| 12 | int array[100]; |
| 13 | SkRandom rand; |
| 14 | |
| 15 | for (int i = 0; i < 1000; i++) { |
| 16 | int j, count = rand.nextRangeU(1, SK_ARRAY_COUNT(array)); |
| 17 | for (j = 0; j < count; j++) { |
| 18 | array[j] = rand.nextS() & 0xFF; |
| 19 | } |
| 20 | SkQSort(array, count, sizeof(int), compare_int); |
| 21 | for (j = 1; j < count; j++) { |
| 22 | REPORTER_ASSERT(reporter, array[j-1] <= array[j]); |
| 23 | } |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // need tests for SkStrSearch |
| 28 | |
| 29 | #include "TestClassDef.h" |
| 30 | DEFINE_TESTCLASS("Sort", SortTestClass, TestSort) |