123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- #include "test.h"
- #include "namespace.h"
- 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> . "
- "<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_Term
- *usr1_uri = LSUP_iriref_new ("#usr1", NULL),
- *usr2_uri = LSUP_iriref_new ("#usr2", NULL);
- LSUP_Graph
- *gr1 = LSUP_graph_new(NULL, usr1_uri, NULL),
- *gr2 = LSUP_graph_new(NULL, usr2_uri, NULL);
- LSUP_term_free (usr1_uri);
- LSUP_term_free (usr2_uri);
- ttl_codec.
- 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
- // Store for next test before freeing.
- EXPECT_PASS (LSR_desc_store (rsrc));
- LSR_desc_free (rsrc);
- return 0;
- }
- static int
- test_desc_get ()
- {
- return 0;
- }
- int desc_tests()
- {
- RUN (test_desc_create);
- RUN (test_desc_get);
- return 0;
- }
|