From e555c88b8107caf886da229444c2bed1aaef6c2c Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 28 Jan 2022 23:21:00 +0800 Subject: rename cnp to crf THat file implements support functions for the CNP algorithm, not the algorithm itself. --- src/test/check_crf.c | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 src/test/check_crf.c (limited to 'src/test/check_crf.c') diff --git a/src/test/check_crf.c b/src/test/check_crf.c new file mode 100644 index 0000000..d99a838 --- /dev/null +++ b/src/test/check_crf.c @@ -0,0 +1,149 @@ +#include +#include "../util.h" +#include "../crf.h" + +int +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; + p.y = 1; + + if (crf_find_node(crfp, p) == NULL) { + if (crf_add_node(crfp, p)) { + fleprintf0("fail to add node\n"); + goto cleanup; + } else { + printf("Successfully add node (0, 1)\n"); + } + } + + if (crf_find_node(crfp, p) == NULL) { + fleprintf0("Fail to find node\n"); + goto cleanup; + } else { + printf("Successfully find node for (0, 1)\n"); + } + + pair4 p4 = { 0 }; + + if (crf_add_edge(crfp, p, p4)) { + fleprintf0("Fail to add edge\n"); + goto cleanup; + } else { + printf("Successfully add edge from (0, 1) to zero\n"); + } + + if (crf_find_node(crfp, p)) { + printf("Printing edges for (0, 1)...\n"); + +#define TABLE (crf_find_node(crfp, p)) + + for (NUM i = 0; i < ht_size(TABLE); i++) { +#define KEY (*((pair4**) ht_keys(TABLE)+i)) + printf("(%ld, %ld, %ld, %ld)", + KEY->x, KEY->y, KEY->z, KEY->w); + if (i+1x, prod->y, prod->z, prod->w, grade); + + cleanup: + + destroy_crf(crfp); + + if (pr) destroy_procr(pr); + if (pu) destroy_procu(pu); + if (spap) destroy_spa(spap); + if (prod) free(prod); + + return 0; +} -- cgit v1.2.3-18-g5258