#ifndef _TEST_ASSETS_H #define _TEST_ASSETS_H #include "triple.h" #define NUM_TRP 10 LSUP_Triple *create_triples() { LSUP_Triple *trp; CRITICAL (trp = malloc (NUM_TRP * sizeof (LSUP_Triple))); // These constitute overall 10 individual triples, 8 unique. /* LSUP_uri_init (&terms[0][0], "urn:s:0"); LSUP_uri_init (&terms[0][1], "urn:p:0"); LSUP_uri_init (&terms[0][2], "urn:o:0"); trp[0] = {terms[1][0], terms[1][1], terms[1][2]}; LSUP_uri_init (&terms[1][0], "urn:s:1"); LSUP_uri_init (&terms[1][1], "urn:p:1"); LSUP_uri_init (&terms[1][2], "urn:o:1"); trp[1] = {terms[1][0], terms[1][1], terms[1][2]}; LSUP_uri_init (&terms[2][0], "urn:s:2"); LSUP_uri_init (&terms[2][1], "urn:p:2"); LSUP_uri_init (&terms[2][2], "urn:o:2"); trp[2] = {terms[2][0], terms[2][1], terms[2][2]}; LSUP_uri_init (&terms[3][0], "urn:s:0"); LSUP_uri_init (&terms[3][1], "urn:p:1"); LSUP_uri_init (&terms[3][2], "urn:o:2"); trp[3] = {terms[3][0], terms[3][1], terms[3][2]}; LSUP_uri_init (&terms[4][0], "urn:s:0"); LSUP_uri_init (&terms[4][1], "urn:p:2"); LSUP_term_init (&terms[4][2], LSUP_TERM_LITERAL, "String 1", NULL, NULL); trp[4] = {terms[4][0], terms[4][1], terms[4][2]}; LSUP_uri_init (&terms[5][0], "urn:s:0"); LSUP_uri_init (&terms[5][1], "urn:p:5"); LSUP_term_init( &terms[5][2], LSUP_TERM_LITERAL, "String 1", "xsd:string", NULL); trp[5] = {terms[5][0], terms[5][1], terms[5][2]}; LSUP_uri_init (&terms[6][0], "urn:s:1"); LSUP_uri_init (&terms[6][1], "urn:p:6"); LSUP_term_init( &terms[6][2], LSUP_TERM_LITERAL, "String 1", "xsd:string", "es-ES"); trp[6] = {terms[6][0], terms[6][1], terms[6][2]}; */ 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, 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", NULL); 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_LITERAL, "String 1", "xsd:string", "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