commit 2ab61f51ccb4f9d80e84944ce90d706bdc9d569a
parent c4dd1ad7ffc32e2b2f3a5e7bd45161e133de30ae
Author: olikru <olikru@tkruger.se>
Date: Wed, 24 Apr 2024 22:30:45 +0200
added unit test for prodtree_compute
Diffstat:
1 file changed, 29 insertions(+), 0 deletions(-)
diff --git a/test_angrepp.c b/test_angrepp.c
@@ -8,6 +8,7 @@
#include "pierre.h"
#include "wiener.h"
#include "smallfactor.h"
+#include "prodtree.h"
static uint64_t
test_f(uint64_t x)
@@ -97,6 +98,33 @@ test_smallfactor_euclidean(void)
fmpz_clear(res);
}
+static void
+test_prodtree(void)
+{
+ fmpz_t tre, fem, sju;
+ fmpz_init_set_ui(tre, 3);
+ fmpz_init_set_ui(fem, 5);
+ fmpz_init_set_ui(sju, 7);
+
+ fmpz v[3] = {tre[0], fem[0], sju[0]};
+ fmpz* res;
+ slong lres = prodtree_compute(&res, v, 3);
+
+ assert(lres == 7);
+
+ assert(fmpz_cmp_ui(&res[0], 3) == 0);
+ assert(fmpz_cmp_ui(&res[1], 5) == 0);
+ assert(fmpz_cmp_ui(&res[2], 7) == 0);
+ assert(fmpz_cmp_ui(&res[3], 1) == 0);
+ assert(fmpz_cmp_ui(&res[4], 15) == 0);
+ assert(fmpz_cmp_ui(&res[5], 7) == 0);
+ assert(fmpz_cmp_ui(&res[6], 105) == 0);
+
+ fmpz_clear(tre);
+ fmpz_clear(fem);
+ fmpz_clear(sju);
+}
+
int
main(void)
{
@@ -105,6 +133,7 @@ main(void)
test_pierre_factor();
test_wiener_factor_small_d();
test_smallfactor_euclidean();
+ test_prodtree();
printf("test ok\n");
}