|
@@ -39,6 +39,44 @@ _graph_new (LSUP_StoreType type)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+/// Test creating a graph with a namespaced URI.
|
|
|
|
+static int
|
|
|
|
+_graph_ns_uri (LSUP_StoreType type)
|
|
|
|
+{
|
|
|
|
+ const LSUP_StoreInt *sif = LSUP_store_int (type);
|
|
|
|
+ if (sif->setup_fn) sif->setup_fn (NULL, true);
|
|
|
|
+
|
|
|
|
+ LSUP_NSMap *nsm = LSUP_nsmap_new();
|
|
|
|
+ LSUP_nsmap_add (nsm, "ns1", "urn:ns1#");
|
|
|
|
+ LSUP_nsmap_add (nsm, "ns2", "urn:ns2#");
|
|
|
|
+ LSUP_nsmap_add (nsm, "ns3", "urn:ns3#");
|
|
|
|
+
|
|
|
|
+ LSUP_Graph *gr;
|
|
|
|
+ LSUP_Store *store = NULL;
|
|
|
|
+ if (sif->features & LSUP_STORE_PERM) {
|
|
|
|
+ store = LSUP_store_new (type, NULL, 0);
|
|
|
|
+ store->sif->nsm_put_fn (store->data, nsm, NULL);
|
|
|
|
+ }
|
|
|
|
+ gr = LSUP_graph_new (store, "ns1:gr1", nsm);
|
|
|
|
+ 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);
|
|
|
|
+ ASSERT (
|
|
|
|
+ LSUP_term_equals (LSUP_graph_uri (gr), comp),
|
|
|
|
+ "Namespaced graph URI is incorrect!" );
|
|
|
|
+ LSUP_term_free (comp);
|
|
|
|
+
|
|
|
|
+ LSUP_graph_free (gr);
|
|
|
|
+ if (store) LSUP_store_free (store);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
static int
|
|
static int
|
|
_graph_add (LSUP_StoreType type)
|
|
_graph_add (LSUP_StoreType type)
|
|
{
|
|
{
|
|
@@ -700,6 +738,16 @@ BACKEND_TBL
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+static int test_graph_ns_uri() {
|
|
|
|
+#define ENTRY(a, b) \
|
|
|
|
+ if (_graph_ns_uri (LSUP_STORE_##a) != 0) return -1;
|
|
|
|
+BACKEND_TBL
|
|
|
|
+#undef ENTRY
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
static int test_graph_add() {
|
|
static int test_graph_add() {
|
|
#define ENTRY(a, b) \
|
|
#define ENTRY(a, b) \
|
|
if (_graph_add (LSUP_STORE_##a) != 0) return -1;
|
|
if (_graph_add (LSUP_STORE_##a) != 0) return -1;
|
|
@@ -834,6 +882,7 @@ int graph_tests()
|
|
{
|
|
{
|
|
RUN (test_environment);
|
|
RUN (test_environment);
|
|
RUN (test_graph_new);
|
|
RUN (test_graph_new);
|
|
|
|
+ RUN (test_graph_ns_uri);
|
|
RUN (test_graph_add);
|
|
RUN (test_graph_add);
|
|
RUN (test_graph_get);
|
|
RUN (test_graph_get);
|
|
RUN (test_graph_link_map);
|
|
RUN (test_graph_link_map);
|