123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include "test.h"
- #include "graph.h"
- #include "assets.h"
- static int test_graph_heap()
- {
- LSUP_Graph *gr = LSUP_graph_new(10, "urn:gr:1", LSUP_STORE_MEM);
- ASSERT(strcmp(LSUP_graph_uri(gr)->data, "urn:gr:1") == 0, "Graph URI mismatch!");
- EXPECT_INT_EQ(LSUP_graph_size(gr), 0);
- LSUP_graph_free(gr);
- return 0;
- }
- static int test_graph_add()
- {
- LSUP_Triple *trp = create_triples();
- LSUP_Graph *gr = LSUP_graph_new(NUM_TRP + 2, "urn:gr:2", LSUP_STORE_MEM);
- LSUP_graph_add(gr, trp, NUM_TRP);
- for (int i = 0; i < sizeof(trp); i++) {
- printf("checking triple #%d... ", i);
- ASSERT(LSUP_graph_contains(gr, trp + i), "Triple not in graph!");
- printf("OK.\n");
- }
- free_triples(trp); // gr copied data.
- EXPECT_INT_EQ(LSUP_graph_size(gr), 8);
- LSUP_graph_free(gr);
- return 0;
- }
- int graph_tests()
- {
- RUN(test_graph_heap);
- RUN(test_graph_add);
- return 0;
- }
|