-
Notifications
You must be signed in to change notification settings - Fork 2
/
randu_check.c
53 lines (38 loc) · 1009 Bytes
/
randu_check.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <check.h>
#include <talloc.h>
#include "rngod.h"
#include "randu.h"
struct rngod *randu;
static void randu_init(void) {
randu = rngod_randu_add_default();
}
static void randu_shutdown(void) {
talloc_free(randu);
}
#define RESULT(expected_, randu_) \
do { \
int res_ = randu_->rand(randu_); \
ck_assert_int_eq(expected_, res_); \
} while (0)
START_TEST(test_randu_create) {
ck_assert(randu != NULL);
} END_TEST
START_TEST(test_randu_single_value) {
RESULT(65539, randu);
} END_TEST
START_TEST(test_randu_many_values) {
RESULT(65539, randu);
RESULT(393225, randu);
RESULT(1769499, randu);
RESULT(7077969, randu);
} END_TEST
int
randu_check(Suite *s) {
TCase *tc_randu = tcase_create("RNG Randu");
tcase_add_checked_fixture(tc_randu, randu_init, randu_shutdown);
suite_add_tcase(s, tc_randu);
tcase_add_test(tc_randu, test_randu_create);
tcase_add_test(tc_randu, test_randu_single_value);
tcase_add_test(tc_randu, test_randu_many_values);
return 0;
}