#include "test.h" #include "graph.h" #include "assets.h" /* TODO Not yet implemented. */ static int __attribute__ ((unused)) test_graph_mem_new () { LSUP_Graph *gr; gr = LSUP_graph_new (LSUP_STORE_MEM); 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_mdb_new () { LSUP_Graph *gr; gr = LSUP_graph_new (LSUP_STORE_MDB); ASSERT (gr != NULL, "Error creating graph!"); EXPECT_PASS (LSUP_graph_set_uri (gr, "urn:gr:1")); EXPECT_STR_EQ (LSUP_graph_uri (gr)->data, "urn:gr:1"); 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_mdb_add() { LSUP_Triple *trp = create_triples(); LSUP_Graph *gr = LSUP_graph_new (LSUP_STORE_MDB); 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_mdb_new); RUN (test_graph_mdb_add); return 0; }