aboutsummaryrefslogtreecommitdiff
path: root/test/src/math/test_subgroups.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/src/math/test_subgroups.c')
-rw-r--r--test/src/math/test_subgroups.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/src/math/test_subgroups.c b/test/src/math/test_subgroups.c
new file mode 100644
index 0000000..fa81788
--- /dev/null
+++ b/test/src/math/test_subgroups.c
@@ -0,0 +1,31 @@
+/*
+ * ecgen, tool for generating Elliptic curve domain parameters
+ * Copyright (C) 2017 J08nY
+ */
+#include "gen/types.h"
+#include "math/subgroups.h"
+#include <criterion/criterion.h>
+
+void setup(void) {
+ pari_init(1000000000, 1000000);
+}
+
+TestSuite(subgroups, .init=setup);
+
+Test(subgroups, test_prime_factors) {
+ curve_t curve = {.order = stoi(12)};
+ config_t cfg = {.prime = false};
+ GEN divs = subgroups_prime(&curve, &cfg);
+ GEN vec = gtocol0(gen_0, 2);
+ gel(vec, 1) = stoi(2);
+ gel(vec, 2) = stoi(3);
+ cr_assert(gequal(divs, vec), "Factors not equal!");
+}
+
+Test(subgroups, test_prime_prime) {
+ curve_t curve = {.order = stoi(5)};
+ config_t cfg = {.prime = true};
+ GEN divs = subgroups_prime(&curve, &cfg);
+ GEN vec = gtocol(stoi(5));
+ cr_assert(gequal(divs, vec), "Factors not equal!");
+} \ No newline at end of file