summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-01-28 23:21:00 +0800
committerJSDurand <mmemmew@gmail.com>2022-01-28 23:22:22 +0800
commite555c88b8107caf886da229444c2bed1aaef6c2c (patch)
tree239894914a881800e244f10090fa97822b0352a3 /src/test
parent8ace61933130416a0b8a6b250de681a606439f48 (diff)
rename cnp to crf
THat file implements support functions for the CNP algorithm, not the algorithm itself.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/check_crf.c (renamed from src/test/check_cnp.c)48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/test/check_cnp.c b/src/test/check_crf.c
index 2fbaac7..d99a838 100644
--- a/src/test/check_cnp.c
+++ b/src/test/check_crf.c
@@ -1,6 +1,6 @@
#include <stdio.h>
#include "../util.h"
-#include "../cnp.h"
+#include "../crf.h"
int
main(int UNUSED argc, char ** UNUSED argv)
@@ -8,8 +8,12 @@ main(int UNUSED argc, char ** UNUSED argv)
procr *pr = NULL;
procu *pu = NULL;
+ spa *spap = NULL;
+
prodecor *prod = NULL;
+ /* check crf */
+
crf *crfp = new_crf();
pair2 p = { 0 };
p.x = 0;
@@ -57,6 +61,47 @@ main(int UNUSED argc, char ** UNUSED argv)
#undef TABLE
#undef KEY
+ /* check spa */
+
+ spap = new_spa();
+
+ if (spap == NULL) {
+ fleprintf0("fail to have new spa\n");
+ goto cleanup;
+ }
+
+ pair3 p3 = (pair3) { 0 };
+ p3.x = 0;
+ p3.y = 1;
+ p3.z = 10;
+
+ if (spa_insert(spap, p3)) {
+ fleprintf0("Fail to insert\n");
+ goto cleanup;
+ }
+
+ printf("Successfully inserted into SPA\n");
+
+ if (spa_belong(spap, p3)) {
+ printf("Successfully found p3\n");
+ } else {
+ fleprintf0("Fail to find p3\n");
+ goto cleanup;
+ }
+
+ pair2 first_two = (pair2) { 0 };
+ first_two.x = 0;
+ first_two.y = 1;
+
+ if (spa_find(spap, first_two)) {
+ printf("Successfully found p2\n");
+ } else {
+ fleprintf0("Fail to find p2\n");
+ goto cleanup;
+ }
+
+ /* check prodecor */
+
BOOL error = 0;
pr = new_procr(10, &error);
@@ -97,6 +142,7 @@ main(int UNUSED argc, char ** UNUSED argv)
if (pr) destroy_procr(pr);
if (pu) destroy_procu(pu);
+ if (spap) destroy_spa(spap);
if (prod) free(prod);
return 0;