Go to the source code of this file.
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 45 of file testqsort.c.
47 static int nums[1024 * 100];
56 if (argv[1][0] ==
'0' && argv[1][1] ==
'x')
57 success =
SDL_sscanf(argv[1] + 2,
"%llx", &seed);
65 if (seed <= 0xffffffff)
70 SDLTest_RandomInit(&rndctx, (
unsigned int)(seed >> 32), (
unsigned int)(seed & 0xffffffff));
76 SDL_Log(
"Using random seed 0x%08x%08x\n", rndctx.
x, rndctx.
c);
82 for (
i = 0;
i < arraylen;
i++) {
85 test_sort(
"already sorted", nums, arraylen);
87 for (
i = 0;
i < arraylen;
i++) {
90 nums[arraylen-1] = -1;
91 test_sort(
"already sorted except last element", nums, arraylen);
93 for (
i = 0;
i < arraylen;
i++) {
94 nums[
i] = (arraylen-1) -
i;
96 test_sort(
"reverse sorted", nums, arraylen);
98 for (
i = 0;
i < arraylen;
i++) {
101 test_sort(
"random sorted", nums, arraylen);
References SDLTest_RandomContext::c, i, iteration(), SDL_arraysize, SDL_Log, SDL_LOG_CATEGORY_APPLICATION, SDL_LogError, SDL_sscanf, SDLTest_RandomInit(), SDLTest_RandomInitTime(), SDLTest_RandomInt, test_sort(), and SDLTest_RandomContext::x.
◆ num_compare()
static int num_compare |
( |
const void * |
_a, |
|
|
const void * |
_b |
|
) |
| |
|
static |
Definition at line 16 of file testqsort.c.
18 const int a = *((
const int *) _a);
19 const int b = *((
const int *) _b);
20 return (
a <
b) ? -1 : ((
a >
b) ? 1 : 0);
Referenced by test_sort().
◆ test_sort()
static void test_sort |
( |
const char * |
desc, |
|
|
int * |
nums, |
|
|
const int |
arraylen |
|
) |
| |
|
static |