blob: b397ff98cae4b8a732b5660290799a16721f815f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "../kit/secure_random.h"
#include <string.h>
#define KIT_TEST_FILE secure_random
#include "../kit/test.h"
TEST("secure random") {
i32 v[20];
memset(v, 0, sizeof v);
REQUIRE_EQ(secure_random(40, v), KIT_OK);
REQUIRE_EQ(secure_random(40, v + 10), KIT_OK);
int repeats = 0;
for (i32 i = 1; i < (i32) (sizeof v / sizeof *v); i++)
for (i32 j = 0; j < i; j++)
if (v[i] == v[j])
repeats++;
REQUIRE_EQ(repeats, 0);
}
#undef KIT_TEST_FILE
|