aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/ecgen.sh2
-rw-r--r--test/src/exhaustive/test_supersingular.c32
2 files changed, 30 insertions, 4 deletions
diff --git a/test/ecgen.sh b/test/ecgen.sh
index 3a94564..e9fbe66 100755
--- a/test/ecgen.sh
+++ b/test/ecgen.sh
@@ -101,7 +101,7 @@ function anomalous() {
function supersingular() {
start_test
- assert_raises "${ecgen} --fp --supersingular -r 20"
+ assert_raises "${ecgen} --fp --supersingular -r -c 5 20"
out=$(${ecgen} --fp --supersingular -r 20 2>/dev/null)
p=$(echo $out | ${JSON} -x field\",\"p | cut -f 2)
order=$(echo $out | ${JSON} -x ^0,\"order\" | cut -f 2)
diff --git a/test/src/exhaustive/test_supersingular.c b/test/src/exhaustive/test_supersingular.c
index c93944f..6c8a81d 100644
--- a/test/src/exhaustive/test_supersingular.c
+++ b/test/src/exhaustive/test_supersingular.c
@@ -4,13 +4,39 @@
*/
#include <criterion/criterion.h>
+#include <criterion/parameterized.h>
#include "exhaustive/supersingular.h"
#include "test/default.h"
+#include "test/memory.h"
TestSuite(supersingular, .init = default_setup, .fini = default_teardown);
-Test(supersingular, test_supersingular_gen_eq) {
- GEN p = strtoi("0xebc040451686221f");
+struct supersingular_params {
+ char *p;
+};
+
+void supersingular_params_cleanup(struct criterion_test_params *ctp) {
+ struct supersingular_params *params =
+ (struct supersingular_params *)ctp->params;
+ cr_free(params->p);
+}
+
+ParameterizedTestParameters(supersingular, test_supersingular_gen_eq_examples) {
+ static struct supersingular_params params[3] = {{0}};
+ params[0].p = cr_strdup("0xd5a29f67"); // 0xd5a29f67 -> a = -1, b = 0
+ params[1].p = cr_strdup("0x9420009d"); // 0x9420009d -> from j invariant
+ params[2].p = cr_strdup("0xfac80035"); // 0xfac80035 -> a = 0, b = 1
+
+ size_t nb_params = sizeof(params) / sizeof(struct supersingular_params);
+ return cr_make_param_array(struct supersingular_params, params, nb_params,
+ supersingular_params_cleanup);
+}
+
+ParameterizedTest(struct supersingular_params *param, supersingular,
+ test_supersingular_gen_eq_examples) {
+ cfg->bits = 32;
+ cfg->field = FIELD_PRIME;
+ GEN p = strtoi(param->p);
curve_t curve = {.field = p};
int ret = supersingular_gen_equation(&curve, NULL, OFFSET_B);
@@ -22,4 +48,4 @@ Test(supersingular, test_supersingular_gen_eq) {
cr_assert_neq(glength(e), 0, );
GEN c = ellcard(e, NULL);
cr_assert(equalii(addis(p, 1), c), );
-}
+} \ No newline at end of file