123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #include "test.h"
- #include "namespace.h"
- static int
- test_dres_create()
- {
- char
- *ttl1 = "<urn:s:1> <urn:p:2> <urn:o:2> , <urn:o:1> ; "
- "<urn:p:1> <urn:o:1> . "
- "<urn:s:2> <urn:p:1> <urn:o:1> . ",
- *ttl2 = "<urn:s:20> <urn:p:10> <urn:o:10> . "
- "<urn:s:10> <urn:p:10> <urn:o:10> ; "
- "<urn:p:20> <urn:o:20> , <urn:o:10> . ";
- LSUP_Graph *data[3] = {NULL};
- FILE *input;
- char *err;
- size_t ct;
- 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);
- 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);
- // Create resource.
- LSR_Dres *rsrc;
- EXPECT_PASS (LSR_dres_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 (data[0]);
- LSUP_graph_free (data[1]);
- LSUP_Graph *md_gr = LSR_dres_metadata (rsrc);
- ASSERT (md_gr != NULL, "Error retrieving metadata graph!");
- ASSERT (
- LSUP_term_equals (
- LSUP_graph_uri (md_gr), LSUP_graph_uri (rsrc->admin_data)),
- "Metadata function URI is incorrect!");
- ASSERT (sizeof(md_gr) > 0, "No metadata found for resource!");
- LSUP_Term
- *rsrc_urn = LSR_dres_urn (rsrc),
- *main_urn = LSR_id_to_urn (rsrc->id, "__main"),
- *admin_urn = LSR_id_to_urn (rsrc->id, "__admin"),
- *usr1_urn = LSR_id_to_urn (rsrc->id, "usr1"),
- *usr2_urn = LSR_id_to_urn (rsrc->id, "usr2");
- // TODO tests:
- // * Existence of admin graph
- // * Existence of main graph
- // * Existence of user graphs
- // * Linkage of main, admin, and user graphs
- // * Size of user graphs
- // * Spot-test triples in user graphs
- ASSERT (
- LSUP_term_equals (main_urn, LSUP_graph_uri (rsrc->main_data)),
- "Main graph URI is incorrect!");
- ASSERT (
- LSUP_term_equals (admin_urn, LSUP_graph_uri (md_gr)),
- "Admin graph URI is incorrect!");
- LSUP_Term *t1 = LSUP_iriref_new ("foaf:topic", LSUP_default_nsm);
- LSUP_Triple *test_spo = LSUP_triple_new (main_urn, t1, rsrc_urn);
- /*
- ASSERT (
- LSUP_graph_contains (rsrc->main_data, test_spo),
- "Main data missing topic triple!");
- */
- // TODO
- LSUP_term_free (usr2_urn);
- LSUP_term_free (usr1_urn);
- LSUP_term_free (admin_urn);
- LSUP_term_free (main_urn);
- LSUP_term_free (rsrc_urn);
- LSUP_graph_free (md_gr);
- // Store for next test before freeing.
- EXPECT_PASS (LSR_dres_store (rsrc));
- LSR_dres_free (rsrc);
- return 0;
- }
- static int
- test_dres_get ()
- {
- return 0;
- }
- int dres_tests()
- {
- RUN (test_dres_create);
- RUN (test_dres_get);
- return 0;
- }
|