12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #include "test.h"
- #include "graph.h"
- #include "assets.h"
- static int test_graph_new()
- {
- LSUP_Graph *gr;
- EXPECT_PASS(LSUP_graph_new(LSUP_STORE_MEM, &gr));
- EXPECT_PASS(LSUP_graph_set_uri(gr, "urn:gr:1"));
- EXPECT_STR_EQ(LSUP_graph_uri(gr)->data, "urn:gr:1");
- EXPECT_PASS(LSUP_graph_resize(gr, 10));
- EXPECT_INT_EQ(LSUP_graph_capacity(gr), 10);
- 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(LSUP_STORE_MEM, &gr);
- LSUP_graph_resize(gr, NUM_TRP + 2);
- size_t ct;
- LSUP_graph_add_trp(gr, trp, NUM_TRP, &ct);
- 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_new);
- RUN(test_graph_add);
- return 0;
- }
|