123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #ifndef _TEST_ASSETS_TRIPLES_H
- #define _TEST_ASSETS_TRIPLES_H
- #include "term.h"
- #define NUM_TRP 10
- LSUP_Triple **create_triples()
- {
- LSUP_NSMap *nsm = LSUP_nsmap_new ();
- LSUP_nsmap_add (nsm, "ns1", "urn:s:");
- LSUP_nsmap_add (nsm, "ns2", "urn:p:");
- LSUP_Term
- *s0 = LSUP_iriref_new ("urn:s:0", NULL),
- *s5 = LSUP_iriref_new ("ns1:0", nsm),
- *p2 = LSUP_iriref_new ("urn:p:2", NULL),
- *p4 = LSUP_iriref_new ("ns2:2", nsm),
- *o5 = LSUP_literal_new (
- "String 1",
- LSUP_iriref_new ("urn:mydatatype:string", NULL));
- LSUP_Triple **trp = calloc (sizeof (LSUP_Triple), NUM_TRP + 1);
- trp[0] = LSUP_triple_new (
- s0,
- LSUP_iriref_new ("urn:p:0", NULL),
- LSUP_iriref_new ("urn:o:0", NULL));
- trp[1] = LSUP_triple_new (
- LSUP_iriref_new ("urn:s:1", NULL),
- LSUP_iriref_new ("urn:p:1", NULL),
- LSUP_iriref_new ("urn:o:1", NULL));
- trp[2] = LSUP_triple_new (
- LSUP_iriref_new ("urn:s:2", NULL),
- p2,
- LSUP_iriref_new ("urn:o:2", NULL));
- trp[3] = LSUP_triple_new (
- LSUP_iriref_new ("urn:s:0", NULL),
- LSUP_iriref_new ("urn:p:1", NULL),
- LSUP_iriref_new ("urn:o:2", NULL));
- trp[4] = LSUP_triple_new (
- LSUP_iriref_new ("urn:s:0", NULL),
- p4,
- LSUP_literal_new ("String 1", NULL));
- trp[5] = LSUP_triple_new (s5, LSUP_iriref_new ("urn:p:5", NULL), o5);
- trp[6] = LSUP_triple_new (
- LSUP_iriref_new ("urn:s:1", NULL),
- LSUP_iriref_new ("urn:p:6", NULL),
- LSUP_lt_literal_new ("String 1", "es-ES"));
- // Unique triple from reused pointers. Do not double-free.
- trp[7] = LSUP_triple_new (s0, p2, o5);
- // Duplicate of trp[7]. Do not double-free.
- trp[8] = LSUP_triple_new (s0, p2, o5);
- // Duplicate of trp[7] from different terms but semantically
- // identical. Do not double-free.
- trp[9] = LSUP_triple_new (s5, p4, o5);
- return trp;
- }
- void free_triples (LSUP_Triple **trp)
- {
- LSUP_nsmap_free (LSUP_iriref_nsm (trp[4]->p));
- // Last three triples are second pointers.
- for (int i=0; i < NUM_TRP - 3; i++)
- LSUP_triple_free (trp[i]);
- free (trp[7]);
- free (trp[8]);
- free (trp[9]);
- free(trp);
- }
- #endif /* _TEST_ASSETS_TRIPLES_H */
|