summaryrefslogtreecommitdiff
path: root/src/test/check_cnp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/check_cnp.c')
-rw-r--r--src/test/check_cnp.c103
1 files changed, 0 insertions, 103 deletions
diff --git a/src/test/check_cnp.c b/src/test/check_cnp.c
deleted file mode 100644
index 2fbaac7..0000000
--- a/src/test/check_cnp.c
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <stdio.h>
-#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+1<ht_size(TABLE)) printf(", ");
- else printf("\n");
- }
- }
-
-#undef TABLE
-#undef KEY
-
- BOOL error = 0;
-
- pr = new_procr(10, &error);
- pu = new_procu(10, &error);
-
- p4 = (pair4) { 0 };
-
- p4.x = 1;
-
- if (desc_add(pr, pu, 2, p4)) {
- fleprintf0("Fail to add descriptor\n");
- goto cleanup;
- }
-
- NUM grade = 0;
-
- prod = pop_procr(pr, pu, &grade);
-
- if (prod == NULL) {
- printf("The first pop failed. "
- "But maybe it occurs due to some misses in the minimal "
- "weight.\n");
- printf("So we shall pop again\n");
- prod = pop_procr(pr, pu, &grade);
-
- if (prod == NULL) {
- fleprintf0("Fail to pop\n");
- goto cleanup;
- }
- }
-
- printf("popped a process descriptor: (%ld, %ld, %ld, %ld, %ld)\n",
- prod->x, 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;
-}