mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-12-22 23:29:27 +00:00
49 lines
838 B
C++
49 lines
838 B
C++
/* Conformance Test 19.7.0.1: Verification of rand, srand library functions */
|
|
|
|
#include <stdlib.h>
|
|
|
|
main ()
|
|
{
|
|
int i, j, array1 [20], array30 [20];
|
|
|
|
for (i = 0; i < 20; i++)
|
|
{
|
|
j = rand ();
|
|
if ((j < 0 ) || (j > 32767))
|
|
goto Fail;
|
|
array1 [i] = j;
|
|
}
|
|
|
|
srand (30);
|
|
for (i = 0; i < 20; i++)
|
|
{
|
|
j = rand ();
|
|
if ((j < 0 ) || (j > 32767))
|
|
goto Fail;
|
|
array30 [i] = j;
|
|
}
|
|
|
|
srand (1);
|
|
for (i = 0; i < 20; i++)
|
|
{
|
|
j = rand ();
|
|
if (j != array1 [i])
|
|
goto Fail;
|
|
}
|
|
|
|
srand (30);
|
|
for (i = 0; i < 20; i++)
|
|
{
|
|
j = rand ();
|
|
if (j != array30 [i])
|
|
goto Fail;
|
|
}
|
|
|
|
|
|
printf ("Passed Conformance Test 19.7.0.1\n");
|
|
return;
|
|
|
|
Fail:
|
|
printf ("Failed Conformance Test 19.7.0.1\n");
|
|
}
|