blob: 6d287c5004292ec49685b2b4dfdfb4ea3c22508c [file] [log] [blame]
reed@android.com5e5adfd2009-03-07 03:39:23 +00001#include "Test.h"
2#include "SkRandom.h"
3#include "SkTSearch.h"
4
5extern "C" {
6 int compare_int(const void* a, const void* b) {
7 return *(const int*)a - *(const int*)b;
8 }
9}
10
11static 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"
30DEFINE_TESTCLASS("Sort", SortTestClass, TestSort)