|
@@ -4,71 +4,6 @@
|
|
|
static int
|
|
|
test_desc_create()
|
|
|
{
|
|
|
- /*
|
|
|
- LSUP_Term *terms1[] = {
|
|
|
- LSUP_iriref_new ("urn:s:1", NULL),
|
|
|
- LSUP_iriref_new ("urn:s:2", NULL),
|
|
|
- LSUP_iriref_new ("urn:p:1", NULL),
|
|
|
- LSUP_iriref_new ("urn:p:2", NULL),
|
|
|
- LSUP_iriref_new ("urn:o:1", NULL),
|
|
|
- LSUP_iriref_new ("urn:o:2", NULL),
|
|
|
- };
|
|
|
- LSUP_Term *terms2[] = {
|
|
|
- LSUP_iriref_new ("urn:s:10", NULL),
|
|
|
- LSUP_iriref_new ("urn:s:20", NULL),
|
|
|
- LSUP_iriref_new ("urn:p:10", NULL),
|
|
|
- LSUP_iriref_new ("urn:p:20", NULL),
|
|
|
- LSUP_iriref_new ("urn:o:10", NULL),
|
|
|
- LSUP_iriref_new ("urn:o:20", NULL),
|
|
|
- };
|
|
|
-
|
|
|
- LSUP_Triple *trp1[] = {
|
|
|
- LSUP_triple_new (terms1[0], terms1[2], terms1[4]),
|
|
|
- LSUP_triple_new (terms1[0], terms1[3], terms1[4]),
|
|
|
- LSUP_triple_new (terms1[0], terms1[3], terms1[5]),
|
|
|
- LSUP_triple_new (terms1[1], terms1[2], terms1[4]),
|
|
|
- NULL
|
|
|
- };
|
|
|
- LSUP_Triple *trp2[] = {
|
|
|
- LSUP_triple_new (terms2[0], terms2[2], terms2[4]),
|
|
|
- LSUP_triple_new (terms2[0], terms2[3], terms2[4]),
|
|
|
- LSUP_triple_new (terms2[0], terms2[3], terms2[5]),
|
|
|
- LSUP_triple_new (terms2[1], terms2[2], terms2[4]),
|
|
|
- NULL
|
|
|
- };
|
|
|
-
|
|
|
- LSUP_Term *usr1_uri = LSUP_iriref_new ("#usr1", NULL);
|
|
|
- LSUP_Graph *gr1 = LSUP_graph_new (NULL, usr1_uri, NULL);
|
|
|
- LSUP_term_free (usr1_uri);
|
|
|
- ASSERT (gr1, "Error creating graph!");
|
|
|
- EXPECT_PASS (LSUP_graph_add (gr1, trp1, NULL));
|
|
|
-
|
|
|
- for (size_t i = 0; trp1[i]; i++)
|
|
|
- free (trp1[i]);
|
|
|
-
|
|
|
- LSUP_Term *usr2_uri = LSUP_iriref_new ("#usr2", NULL);
|
|
|
- LSUP_Graph *gr2 = LSUP_graph_new (NULL, usr2_uri, NULL);
|
|
|
- LSUP_term_free (usr2_uri);
|
|
|
- ASSERT (gr2, "Error creating graph!");
|
|
|
- EXPECT_PASS (LSUP_graph_add (gr2, trp2, NULL));
|
|
|
-
|
|
|
- char *tmp = NULL;
|
|
|
- void *it;
|
|
|
- it = ttl_codec.encode_graph_init(gr1);
|
|
|
- while (ttl_codec.encode_graph_iter (it, &tmp) != LSUP_END)
|
|
|
- log_info ("gr1: %s\n", tmp);
|
|
|
- ttl_codec.encode_graph_done (it);
|
|
|
-
|
|
|
- it = ttl_codec.encode_graph_init(gr2);
|
|
|
- while (ttl_codec.encode_graph_iter (it, &tmp) != LSUP_END)
|
|
|
- log_info ("gr2: %s\n", tmp);
|
|
|
- ttl_codec.encode_graph_done (it);
|
|
|
-
|
|
|
- free (tmp);
|
|
|
-
|
|
|
- for (size_t i = 0; trp2[i]; i++)
|
|
|
- free (trp2[i]);
|
|
|
- */
|
|
|
char
|
|
|
*ttl1 = "<urn:s:1> <urn:p:2> <urn:o:2> , <urn:o:1> ; "
|
|
|
"<urn:p:1> <urn:o:1> . "
|
|
@@ -77,37 +12,40 @@ test_desc_create()
|
|
|
"<urn:s:10> <urn:p:10> <urn:o:10> ; "
|
|
|
"<urn:p:20> <urn:o:20> , <urn:o:10> . ";
|
|
|
|
|
|
- LSUP_Term
|
|
|
- *usr1_uri = LSUP_iriref_new ("#usr1", NULL),
|
|
|
- *usr2_uri = LSUP_iriref_new ("#usr2", NULL);
|
|
|
+ LSUP_Graph *data[3] = {NULL};
|
|
|
|
|
|
- LSUP_Graph
|
|
|
- *gr1 = LSUP_graph_new(NULL, usr1_uri, NULL),
|
|
|
- *gr2 = LSUP_graph_new(NULL, usr2_uri, NULL);
|
|
|
+ FILE *input;
|
|
|
+ char *err;
|
|
|
+ size_t ct;
|
|
|
|
|
|
- LSUP_term_free (usr1_uri);
|
|
|
- LSUP_term_free (usr2_uri);
|
|
|
+ input = fmemopen (ttl1, strlen (ttl1), "r");
|
|
|
+ ttl_codec.decode_graph(input, data, &ct, &err);
|
|
|
+ LSUP_graph_set_uri (data[0], LSUP_iriref_new ("#usr1", NULL));
|
|
|
+ fclose(input);
|
|
|
|
|
|
- ttl_codec.
|
|
|
+ input = fmemopen (ttl2, strlen (ttl2), "r");
|
|
|
+ ttl_codec.decode_graph(input, data + 1, &ct, &err);
|
|
|
+ LSUP_graph_set_uri (data[1], LSUP_iriref_new ("#usr2", NULL));
|
|
|
+ fclose(input);
|
|
|
|
|
|
+ free(err);
|
|
|
|
|
|
- LSUP_Graph *data[] = {gr1, gr2, NULL};
|
|
|
LSR_Desc *rsrc;
|
|
|
EXPECT_PASS (LSR_desc_new_multi (data, &rsrc));
|
|
|
|
|
|
// Free input handles before using the resource to ensure that these
|
|
|
// pointers are not being referenced by the resource.
|
|
|
- LSUP_graph_free (gr1);
|
|
|
- LSUP_graph_free (gr2);
|
|
|
-
|
|
|
- /*
|
|
|
- for (int i = 0; i < 6; i++) {
|
|
|
- LSUP_term_free (terms1[i]);
|
|
|
- LSUP_term_free (terms2[i]);
|
|
|
- }
|
|
|
- */
|
|
|
-
|
|
|
- // TODO more action
|
|
|
+ LSUP_graph_free (data[0]);
|
|
|
+ LSUP_graph_free (data[1]);
|
|
|
+
|
|
|
+ // TODO tests:
|
|
|
+ // * Existence of admin graph
|
|
|
+ // * Existence of main graph
|
|
|
+ // * Linkage of admin and main graphs
|
|
|
+ // * Existence of user graphs
|
|
|
+ // * Linkage of user graphs
|
|
|
+ // * Size of user graphs
|
|
|
+ // * Spot-test triples in user graphs
|
|
|
|
|
|
// Store for next test before freeing.
|
|
|
EXPECT_PASS (LSR_desc_store (rsrc));
|