From 8ace61933130416a0b8a6b250de681a606439f48 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 28 Jan 2022 11:17:01 +0800 Subject: CNP save point CRF and process descriptors seem to work now. It only remains to implement the set of pending actions before I can work on the driver program. --- src/test/check_cnp.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/test/check_cnp.c (limited to 'src/test') diff --git a/src/test/check_cnp.c b/src/test/check_cnp.c new file mode 100644 index 0000000..2fbaac7 --- /dev/null +++ b/src/test/check_cnp.c @@ -0,0 +1,103 @@ +#include +#include "../util.h" +#include "../cnp.h" + +int +main(int UNUSED argc, char ** UNUSED argv) +{ + procr *pr = NULL; + procu *pu = NULL; + + prodecor *prod = NULL; + + 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 (prod) free(prod); + + return 0; +} -- cgit v1.2.3-18-g5258