Add comment about randomOrder and random seed

This commit is contained in:
Sylvain 2024-08-08 10:21:42 +02:00
parent b5b868044f
commit bd7d4a3752
No known key found for this signature in database
GPG Key ID: 5F87E02E5BC0939E

View File

@ -551,6 +551,13 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
int tmp;
a = SDLTest_RandomIntegerInRange(0, nbSuites - 1);
b = SDLTest_RandomIntegerInRange(0, nbSuites - 1);
/*
* NB: prevent swapping here to make sure the tests start with the same
* random seed (whether they are run in order or not).
* So we consume same number of SDLTest_RandomIntegerInRange() in all cases.
*
* If some random value were used at initialization before the tests start, the --seed wouldn't do the same with or without randomOrder.
*/
/* Swap */
if (randomOrder) {
tmp = arraySuites[b];
@ -602,6 +609,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user
a = SDLTest_RandomIntegerInRange(0, nbTestCases - 1);
b = SDLTest_RandomIntegerInRange(0, nbTestCases - 1);
/* Swap */
/* See previous note */
if (randomOrder) {
tmp = arrayTestCases[b];
arrayTestCases[b] = arrayTestCases[a];