|
@@ -10,10 +10,7 @@
|
|
|
freely.
|
|
|
*/
|
|
|
|
|
|
-#include <stdio.h>
|
|
|
-#include <stdlib.h>
|
|
|
-
|
|
|
-#include "SDL.h"
|
|
|
+#include "SDL_test.h"
|
|
|
|
|
|
static int
|
|
|
num_compare(const void *_a, const void *_b)
|
|
@@ -50,6 +47,33 @@ main(int argc, char *argv[])
|
|
|
static int nums[1024 * 100];
|
|
|
static const int itervals[] = { SDL_arraysize(nums), 12 };
|
|
|
int iteration;
|
|
|
+ SDLTest_RandomContext rndctx;
|
|
|
+
|
|
|
+ if (argc > 1)
|
|
|
+ {
|
|
|
+ int success;
|
|
|
+ Uint64 seed = 0;
|
|
|
+ if (argv[1][0] == '0' && argv[1][1] == 'x')
|
|
|
+ success = SDL_sscanf(argv[1] + 2, "%llx", &seed);
|
|
|
+ else
|
|
|
+ success = SDL_sscanf(argv[1], "%llu", &seed);
|
|
|
+ if (!success)
|
|
|
+ {
|
|
|
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (seed <= 0xffffffff)
|
|
|
+ {
|
|
|
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Seed must be equal or greater than 0x100000000.\n");
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ SDLTest_RandomInit(&rndctx, (unsigned int)(seed >> 32), (unsigned int)(seed & 0xffffffff));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SDLTest_RandomInitTime(&rndctx);
|
|
|
+ }
|
|
|
+ SDL_Log("Using random seed 0x%08x%08x\n", rndctx.x, rndctx.c);
|
|
|
|
|
|
for (iteration = 0; iteration < SDL_arraysize(itervals); iteration++) {
|
|
|
const int arraylen = itervals[iteration];
|
|
@@ -72,7 +96,7 @@ main(int argc, char *argv[])
|
|
|
test_sort("reverse sorted", nums, arraylen);
|
|
|
|
|
|
for (i = 0; i < arraylen; i++) {
|
|
|
- nums[i] = random();
|
|
|
+ nums[i] = SDLTest_RandomInt(&rndctx);
|
|
|
}
|
|
|
test_sort("random sorted", nums, arraylen);
|
|
|
}
|