aboutsummaryrefslogtreecommitdiff
path: root/test/src/util/test_random.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/util/test_random.c')
-rw-r--r--test/src/util/test_random.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/src/util/test_random.c b/test/src/util/test_random.c
index bb632a6..be45f95 100644
--- a/test/src/util/test_random.c
+++ b/test/src/util/test_random.c
@@ -4,6 +4,7 @@
*/
#include <criterion/criterion.h>
+#include "math/poly.h"
#include "test/default.h"
#include "util/random.h"
@@ -30,3 +31,20 @@ Test(random, test_random_int) {
cr_assert_geq(cmpii(j, int2n(9)), 0, );
}
}
+
+Test(random, test_random_field_element_fp) {
+ GEN fp = random_int(25);
+ for (size_t i = 0; i < 100; ++i) {
+ GEN j = random_field_element(fp);
+ cr_assert_geq(cmpii(j, gen_0), 0, );
+ cr_assert_lt(cmpii(j, fp), 0, );
+ }
+}
+
+Test(random, test_random_field_element_f2m) {
+ GEN f2m = poly_find_gen(23);
+ for (size_t i = 0; i < 100; ++i) {
+ GEN j = random_field_element(f2m);
+ cr_assert_not_null(j, );
+ }
+} \ No newline at end of file