summaryrefslogtreecommitdiff
path: root/source/test/unittests/secure_random.test.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/test/unittests/secure_random.test.c')
-rw-r--r--source/test/unittests/secure_random.test.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/test/unittests/secure_random.test.c b/source/test/unittests/secure_random.test.c
new file mode 100644
index 0000000..ec0a7b2
--- /dev/null
+++ b/source/test/unittests/secure_random.test.c
@@ -0,0 +1,22 @@
+#include "../../kit/secure_random.h"
+#include <string.h>
+
+#define KIT_TEST_FILE secure_random
+#include "../../kit_test/test.h"
+
+TEST("secure random") {
+ int v[20];
+ memset(v, 0, sizeof v);
+
+ secure_random(40, v);
+ secure_random(40, v + 10);
+
+ int repeats = 0;
+
+ for (int i = 1; i < sizeof v / sizeof *v; i++)
+ for (int j = 0; j < i; j++)
+ if (v[i] == v[j])
+ repeats++;
+
+ REQUIRE(repeats == 0);
+}