#ifndef _TEST_ASSETS_H #define _TEST_ASSETS_H #include "term.h" #define NUM_TRP 10 LSUP_Triple *create_triples() { LSUP_Triple *trp; // Leave 1 spare NULL as a sentinel trp = calloc (NUM_TRP + 1, sizeof (LSUP_Triple)); if (!trp) abort(); trp[0].s = LSUP_uri_new ("urn:s:0"); trp[0].p = LSUP_uri_new ("urn:p:0"); trp[0].o = LSUP_uri_new ("urn:o:0"); trp[1].s = LSUP_uri_new ("urn:s:1"); trp[1].p = LSUP_uri_new ("urn:p:1"); trp[1].o = LSUP_uri_new ("urn:o:1"); trp[2].s = LSUP_uri_new ("urn:s:2"); trp[2].p = LSUP_uri_new ("urn:p:2"); trp[2].o = LSUP_uri_new ("urn:o:2"); trp[3].s = LSUP_uri_new ("urn:s:0"); trp[3].p = LSUP_uri_new ("urn:p:1"); trp[3].o = LSUP_uri_new ("urn:o:2"); trp[4].s = LSUP_uri_new ("urn:s:0"); trp[4].p = LSUP_uri_new ("urn:p:2"); trp[4].o = LSUP_term_new (LSUP_TERM_LITERAL, "String 1", NULL); trp[5].s = LSUP_uri_new ("urn:s:0"); trp[5].p = LSUP_uri_new ("urn:p:5"); trp[5].o = LSUP_term_new(LSUP_TERM_LITERAL, "String 1", "xsd:string"); trp[6].s = LSUP_uri_new ("urn:s:1"); trp[6].p = LSUP_uri_new ("urn:p:6"); trp[6].o = LSUP_term_new(LSUP_TERM_LT_LITERAL, "String 1", "es-ES"); // Unique triple from reused pointers. Do not double-free. trp[7].s = trp[0].s; // trp[7].p = trp[2].p; // trp[7].o = trp[5].o; // "String 1"^^xsd:string // Duplicate of trp[7]. Do not double-free. trp[8].s = trp[0].s; trp[8].p = trp[2].p; trp[8].o = trp[5].o; // Duplicate of trp[7] from different pointers with same value. // Do not double-free. trp[9].s = trp[5].s; trp[9].p = trp[4].p; trp[9].o = trp[5].o; return trp; } void free_triples (LSUP_Triple *trp) { // Last three triples are second pointers. for (int i=0; i < NUM_TRP - 3; i++) { LSUP_term_free (trp[i].s); LSUP_term_free (trp[i].p); LSUP_term_free (trp[i].o); } free (trp); } #endif