summaryrefslogtreecommitdiff
path: root/source/test/unittests/secure_random.test.c
blob: bde68a5ad3c6b93ab1b6e9bf727db354f8ef8789 (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/test.h"

TEST("secure random") {
  int i, j;

  int v[20];
  memset(v, 0, sizeof v);

  secure_random(40, v);
  secure_random(40, v + 10);

  int repeats = 0;

  for (i = 1; i < sizeof v / sizeof *v; i++)
    for (j = 0; j < i; j++)
      if (v[i] == v[j])
        repeats++;

  REQUIRE(repeats == 0);
}