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);
64 if (seed <= ((
Uint64)0xffffffff)) {
68 SDLTest_RandomInit(&rndctx, (
unsigned int)(seed >> 32), (
unsigned int)(seed & 0xffffffff));
74 SDL_Log(
"Using random seed 0x%08x%08x\n", rndctx.
x, rndctx.
c);
80 for (
i = 0;
i < arraylen;
i++) {
83 test_sort(
"already sorted", nums, arraylen);
85 for (
i = 0;
i < arraylen;
i++) {
88 nums[arraylen-1] = -1;
89 test_sort(
"already sorted except last element", nums, arraylen);
91 for (
i = 0;
i < arraylen;
i++) {
92 nums[
i] = (arraylen-1) -
i;
94 test_sort(
"reverse sorted", nums, arraylen);
96 for (
i = 0;
i < arraylen;
i++) {
99 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 |