|
@@ -10,10 +10,10 @@ _graph_new (LSUP_StoreType type)
|
|
|
LSUP_Graph *gr;
|
|
|
LSUP_Store *store = NULL;
|
|
|
if (type == LSUP_STORE_HTABLE) {
|
|
|
- gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (NULL, NULL);
|
|
|
} else {
|
|
|
store = LSUP_store_new (type, NULL, 0, true);
|
|
|
- gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (store, NULL);
|
|
|
}
|
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
|
|
|
@@ -56,25 +56,22 @@ _graph_ns_uri (LSUP_StoreType type)
|
|
|
|
|
|
log_info("Testing NSM for graph store type: %d", type);
|
|
|
|
|
|
- LSUP_NSMap *nsm = LSUP_nsmap_new();
|
|
|
for (int i = 0; nsdata[i][0]; i++)
|
|
|
- EXPECT_PASS (LSUP_nsmap_add (nsm, nsdata[i][0], nsdata[i][1]));
|
|
|
+ EXPECT_PASS (LSUP_nsmap_add (nsdata[i][0], nsdata[i][1]));
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (store, "ns1:gr1", nsm);
|
|
|
+ LSUP_Graph *gr;
|
|
|
+ gr = LSUP_graph_new_ns (store, NULL);
|
|
|
+ ASSERT (gr == NULL, "NS graph URI cannot be NULL!");
|
|
|
+ gr = LSUP_graph_new_ns (store, "ns1:gr1");
|
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
|
|
|
|
- ASSERT (
|
|
|
- LSUP_graph_uri (gr)->type == LSUP_TERM_NS_IRIREF,
|
|
|
- "Namespace prefixing failed!");
|
|
|
-
|
|
|
- LSUP_Term *comp = LSUP_iriref_new ("urn:ns1#gr1", NULL);
|
|
|
+ LSUP_Term *comp = LSUP_iriref_new ("urn:ns1#gr1");
|
|
|
ASSERT (
|
|
|
LSUP_term_equals (LSUP_graph_uri (gr), comp),
|
|
|
"Namespaced graph URI is incorrect!" );
|
|
|
LSUP_term_free (comp);
|
|
|
|
|
|
LSUP_graph_free (gr);
|
|
|
- LSUP_nsmap_free (nsm);
|
|
|
LSUP_store_free (store);
|
|
|
|
|
|
return 0;
|
|
@@ -91,7 +88,7 @@ _graph_add (LSUP_StoreType type)
|
|
|
if (type == LSUP_STORE_HTABLE) store = NULL;
|
|
|
else store = LSUP_store_new (type, NULL, 0, true);
|
|
|
|
|
|
- gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (store, NULL);
|
|
|
ASSERT (gr != NULL, "Error creating graph!");
|
|
|
|
|
|
size_t ct;
|
|
@@ -115,7 +112,7 @@ _graph_add (LSUP_StoreType type)
|
|
|
// Check size again after freeing triples.
|
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr), 8);
|
|
|
|
|
|
- LSUP_Graph *gr2 = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ LSUP_Graph *gr2 = LSUP_graph_new (NULL, NULL);
|
|
|
|
|
|
// Test equality against empty graph.
|
|
|
ASSERT (!LSUP_graph_equals (gr, gr2), "Graphs should not be equal!");
|
|
@@ -142,8 +139,8 @@ _graph_get (LSUP_StoreType type)
|
|
|
if (type == LSUP_STORE_HTABLE) store = NULL;
|
|
|
else store = LSUP_store_new (type, NULL, 0, true);
|
|
|
LSUP_Graph
|
|
|
- *gr1 = LSUP_graph_new (store, NULL, NULL),
|
|
|
- *gr2 = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ *gr1 = LSUP_graph_new (store, NULL),
|
|
|
+ *gr2 = LSUP_graph_new (store, NULL);
|
|
|
|
|
|
ASSERT (gr1 != NULL, "Error creating graph!");
|
|
|
ASSERT (gr2 != NULL, "Error creating graph!");
|
|
@@ -198,7 +195,7 @@ _graph_link_map (LSUP_StoreType type)
|
|
|
LSUP_Store *store;
|
|
|
if (type == LSUP_STORE_HTABLE) store = NULL;
|
|
|
else store = LSUP_store_new (type, NULL, 0, true);
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ LSUP_Graph *gr = LSUP_graph_new (store, NULL);
|
|
|
|
|
|
size_t ct;
|
|
|
LSUP_graph_add (gr, trp, &ct);
|
|
@@ -320,8 +317,8 @@ _graph_bool_ops (LSUP_StoreType type)
|
|
|
if (type == LSUP_STORE_HTABLE) store = NULL;
|
|
|
else store = LSUP_store_new (type, NULL, 0, true);
|
|
|
LSUP_Graph
|
|
|
- *gr1 = LSUP_graph_new (store, NULL, NULL),
|
|
|
- *gr2 = LSUP_graph_new (store, NULL, NULL),
|
|
|
+ *gr1 = LSUP_graph_new (store, NULL),
|
|
|
+ *gr2 = LSUP_graph_new (store, NULL),
|
|
|
*gr_dest;
|
|
|
|
|
|
// Add 2 groups of triples to different graphs.
|
|
@@ -342,14 +339,14 @@ _graph_bool_ops (LSUP_StoreType type)
|
|
|
LSUP_graph_add_done (it);
|
|
|
|
|
|
// Test union.
|
|
|
- gr_dest = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr_dest = LSUP_graph_new (store, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_bool_op (LSUP_BOOL_UNION, gr1, gr2, gr_dest));
|
|
|
for (size_t i = 0; i < 8; i++)
|
|
|
ASSERT (LSUP_graph_contains (gr_dest, trp[i]), "Union test failed!");
|
|
|
LSUP_graph_free (gr_dest);
|
|
|
|
|
|
// Test subtraction.
|
|
|
- gr_dest = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr_dest = LSUP_graph_new (store, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_bool_op (
|
|
|
LSUP_BOOL_SUBTRACTION, gr1, gr2, gr_dest));
|
|
|
for (size_t i = 0; i < 3; i++)
|
|
@@ -360,7 +357,7 @@ _graph_bool_ops (LSUP_StoreType type)
|
|
|
gr_dest, trp[i]), "Subtraction test has excess triples!");
|
|
|
LSUP_graph_free (gr_dest);
|
|
|
|
|
|
- gr_dest = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr_dest = LSUP_graph_new (store, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_bool_op (
|
|
|
LSUP_BOOL_SUBTRACTION, gr2, gr1, gr_dest));
|
|
|
for (size_t i = 0; i < 4; i++)
|
|
@@ -372,7 +369,7 @@ _graph_bool_ops (LSUP_StoreType type)
|
|
|
LSUP_graph_free (gr_dest);
|
|
|
|
|
|
// Test intersection.
|
|
|
- gr_dest = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr_dest = LSUP_graph_new (store, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_bool_op (
|
|
|
LSUP_BOOL_INTERSECTION, gr1, gr2, gr_dest));
|
|
|
for (size_t i = 0; i < 3; i++)
|
|
@@ -386,7 +383,7 @@ _graph_bool_ops (LSUP_StoreType type)
|
|
|
LSUP_graph_free (gr_dest);
|
|
|
|
|
|
// Test XOR.
|
|
|
- gr_dest = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr_dest = LSUP_graph_new (store, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_bool_op (LSUP_BOOL_XOR, gr1, gr2, gr_dest));
|
|
|
for (size_t i = 0; i < 3; i++)
|
|
|
ASSERT (LSUP_graph_contains (
|
|
@@ -466,10 +463,10 @@ _graph_lookup (LSUP_StoreType type)
|
|
|
LSUP_Graph *gr;
|
|
|
LSUP_Store *store = NULL;
|
|
|
if (type == LSUP_STORE_HTABLE) {
|
|
|
- gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (NULL, NULL);
|
|
|
} else {
|
|
|
store = LSUP_store_new (type, NULL, 0, true);
|
|
|
- gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (store, NULL);
|
|
|
}
|
|
|
|
|
|
size_t ct;
|
|
@@ -534,10 +531,10 @@ _graph_remove (LSUP_StoreType type)
|
|
|
LSUP_Graph *gr;
|
|
|
LSUP_Store *store = NULL;
|
|
|
if (type == LSUP_STORE_HTABLE) {
|
|
|
- gr = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (NULL, NULL);
|
|
|
} else {
|
|
|
store = LSUP_store_new (type, NULL, 0, true);
|
|
|
- gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (store, NULL);
|
|
|
}
|
|
|
|
|
|
size_t ct;
|
|
@@ -585,7 +582,7 @@ _graph_txn (LSUP_StoreType type)
|
|
|
type == LSUP_STORE_HTABLE ? NULL
|
|
|
: LSUP_store_new (type, NULL, 0, true);
|
|
|
|
|
|
- gr = LSUP_graph_new (store, NULL, NULL);
|
|
|
+ gr = LSUP_graph_new (store, NULL);
|
|
|
|
|
|
void *txn;
|
|
|
size_t ct;
|
|
@@ -619,14 +616,14 @@ static int
|
|
|
_graph_relative (LSUP_StoreType type)
|
|
|
{
|
|
|
LSUP_Term
|
|
|
- *s = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/s1", NULL),
|
|
|
- *s2 = LSUP_iriref_new ("http://onto.knowledgetx.com/gr2/s1", NULL),
|
|
|
- *p = LSUP_iriref_new ("http://onto.knowledgetx.com/vocab/p1", NULL),
|
|
|
- *o = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/o1", NULL),
|
|
|
- *o2 = LSUP_iriref_new ("http://onto.knowledgetx.com/gr2/o1", NULL),
|
|
|
- *c = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/", NULL),
|
|
|
- *rel_s = LSUP_iriref_relative (c, s),
|
|
|
- *rel_o = LSUP_iriref_relative (c, o);
|
|
|
+ *s = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/s1"),
|
|
|
+ *s2 = LSUP_iriref_new ("http://onto.knowledgetx.com/gr2/s1"),
|
|
|
+ *p = LSUP_iriref_new ("http://onto.knowledgetx.com/vocab/p1"),
|
|
|
+ *o = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/o1"),
|
|
|
+ *o2 = LSUP_iriref_new ("http://onto.knowledgetx.com/gr2/o1"),
|
|
|
+ *c = LSUP_iriref_new ("http://onto.knowledgetx.com/gr1/"),
|
|
|
+ *rel_s = LSUP_iriref_new_rel (c, s),
|
|
|
+ *rel_o = LSUP_iriref_new_rel (c, o);
|
|
|
LSUP_Triple *spo[2] = {
|
|
|
LSUP_triple_new (s, p, o),
|
|
|
NULL
|
|
@@ -637,7 +634,7 @@ _graph_relative (LSUP_StoreType type)
|
|
|
type == LSUP_STORE_HTABLE ? NULL
|
|
|
: LSUP_store_new (type, NULL, 0, true);
|
|
|
|
|
|
- LSUP_Graph *gr = LSUP_graph_new (store, c->data, NULL);
|
|
|
+ LSUP_Graph *gr = LSUP_graph_new (store, c->data);
|
|
|
|
|
|
size_t ct;
|
|
|
LSUP_graph_add (gr, spo, &ct);
|
|
@@ -679,9 +676,9 @@ _graph_list (LSUP_StoreType type)
|
|
|
LSUP_Store *store = LSUP_store_new (type, NULL, 0, true);
|
|
|
|
|
|
LSUP_Graph *gg[3] = {
|
|
|
- LSUP_graph_new (store, "urn:gr:1", NULL),
|
|
|
- LSUP_graph_new (store, "urn:gr:2", NULL),
|
|
|
- LSUP_graph_new (store, "urn:gr:3", NULL),
|
|
|
+ LSUP_graph_new (store, "urn:gr:1"),
|
|
|
+ LSUP_graph_new (store, "urn:gr:2"),
|
|
|
+ LSUP_graph_new (store, "urn:gr:3"),
|
|
|
};
|
|
|
|
|
|
LSUP_Triple **trp = create_triples();
|
|
@@ -862,13 +859,13 @@ static int test_graph_copy()
|
|
|
{
|
|
|
LSUP_Triple **trp = create_triples();
|
|
|
|
|
|
- LSUP_Graph *gr1 = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ LSUP_Graph *gr1 = LSUP_graph_new (NULL, NULL);
|
|
|
ASSERT (gr1 != NULL, "Error creating graph!");
|
|
|
|
|
|
LSUP_graph_add (gr1, trp, NULL);
|
|
|
|
|
|
// Copy to graph with same store type.
|
|
|
- LSUP_Graph *gr2 = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ LSUP_Graph *gr2 = LSUP_graph_new (NULL, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr2, NULL, NULL, NULL));
|
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
|
|
|
@@ -880,7 +877,7 @@ static int test_graph_copy()
|
|
|
}
|
|
|
|
|
|
// Copy to graph with a different store type.
|
|
|
- LSUP_Graph *gr3 = LSUP_graph_new (NULL, NULL, NULL);
|
|
|
+ LSUP_Graph *gr3 = LSUP_graph_new (NULL, NULL);
|
|
|
EXPECT_PASS (LSUP_graph_copy_contents (gr1, gr3, NULL, NULL, NULL));
|
|
|
EXPECT_INT_EQ (LSUP_graph_size (gr1), LSUP_graph_size (gr2));
|
|
|
|