|
@@ -1,7 +1,7 @@
|
|
|
#include "test.h"
|
|
|
#include "codec/codec_nt.h"
|
|
|
|
|
|
-#define TERM_CT 10
|
|
|
+#define TERM_CT 11
|
|
|
|
|
|
typedef char nt_str[64];
|
|
|
|
|
@@ -12,17 +12,18 @@ init_terms (void)
|
|
|
LSUP_Term **terms = malloc (TERM_CT * sizeof (*terms));
|
|
|
terms[0] = LSUP_iriref_new("urn:local:s1", NULL);
|
|
|
terms[1] = LSUP_iriref_new("http://example.org/p1", NULL);
|
|
|
- terms[2] = LSUP_literal_new ("hello", NULL);
|
|
|
- terms[3] = LSUP_lt_literal_new ("hello", "en-US");
|
|
|
- terms[4] = LSUP_lt_literal_new ("hello", "es-ES");
|
|
|
- terms[5] = LSUP_literal_new (
|
|
|
+ terms[2] = LSUP_iriref_new("http://example.org/p2", NULL);
|
|
|
+ terms[3] = LSUP_literal_new ("hello", NULL);
|
|
|
+ terms[4] = LSUP_lt_literal_new ("hello", "en-US");
|
|
|
+ terms[5] = LSUP_lt_literal_new ("hello", "es-ES");
|
|
|
+ terms[6] = LSUP_literal_new (
|
|
|
"25",
|
|
|
LSUP_iriref_new ("http://www.w3.org/2001/XMLSchema#integer", NULL));
|
|
|
- terms[6] = LSUP_literal_new (
|
|
|
+ terms[7] = LSUP_literal_new (
|
|
|
"This \\is\\ a \"multi-line\"\n'literal'\t.", NULL);
|
|
|
- terms[7] = LSUP_bnode_new ("bn1");
|
|
|
- terms[8] = LSUP_term_new (LSUP_TERM_UNDEFINED, "bogus", NULL);
|
|
|
- terms[9] = TERM_DUMMY;
|
|
|
+ terms[8] = LSUP_bnode_new ("bn1");
|
|
|
+ terms[9] = LSUP_term_new (LSUP_TERM_UNDEFINED, "bogus", NULL);
|
|
|
+ terms[10] = TERM_DUMMY;
|
|
|
|
|
|
return terms;
|
|
|
}
|
|
@@ -31,6 +32,7 @@ init_terms (void)
|
|
|
static nt_str start_nt[TERM_CT] = {
|
|
|
"<urn:local:s1>",
|
|
|
"<http://example.org/p1> ",
|
|
|
+ "<http://example.org/p2> ",
|
|
|
"\"hello\"^^<http://www.w3.org/2001/XMLSchema#string>",
|
|
|
"\"hello\" @en-US",
|
|
|
"\"hello\"@es-ES # Does \"Hello\" in Spanish mean \"hola\"?",
|
|
@@ -45,6 +47,7 @@ static nt_str start_nt[TERM_CT] = {
|
|
|
static nt_str end_nt[TERM_CT] = {
|
|
|
"<urn:local:s1>",
|
|
|
"<http://example.org/p1>",
|
|
|
+ "<http://example.org/p2>",
|
|
|
"\"hello\"",
|
|
|
"\"hello\"@en-US",
|
|
|
"\"hello\"@es-ES",
|
|
@@ -60,10 +63,10 @@ char *start_nt_doc = (
|
|
|
"<urn:local:s1> <http://example.org/p1> \"hello\" . # Comment here.\n"
|
|
|
"<urn:local:s1> <http://example.org/p1> "
|
|
|
"\"hello\"^^<http://www.w3.org/2001/XMLSchema#string> .\n"
|
|
|
- "<urn:local:s1> <http://example.org/p1>\"hello\"@en-US.\n"
|
|
|
- "<urn:local:s1> <http://example.org/p1>\"hello\"@es-ES .\n"
|
|
|
+ "<urn:local:s1> <http://example.org/p2>\"hello\"@en-US.\n"
|
|
|
+ "<urn:local:s1> <http://example.org/p2>\"hello\"@es-ES .\n"
|
|
|
"# Some comments\n# To make it a bit \n #less boring.\n"
|
|
|
- "<urn:local:s1> <http://example.org/p1> _:bn1 .\n"
|
|
|
+ "<urn:local:s1> <http://example.org/p2> _:bn1 .\n"
|
|
|
"_:bn1 <http://example.org/p1> \"hello\"@es-ES.\n"
|
|
|
" _:bn1 <http://example.org/p1> "
|
|
|
"\"25\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n"
|
|
@@ -85,9 +88,9 @@ char *bad_nt_doc = (
|
|
|
// Lines should not be checked in strict order.
|
|
|
char *end_nt_doc[7] = {
|
|
|
"<urn:local:s1> <http://example.org/p1> \"hello\" .\n",
|
|
|
- "<urn:local:s1> <http://example.org/p1> \"hello\"@en-US .\n",
|
|
|
- "<urn:local:s1> <http://example.org/p1> \"hello\"@es-ES .\n",
|
|
|
- "<urn:local:s1> <http://example.org/p1> _:bn1 .\n",
|
|
|
+ "<urn:local:s1> <http://example.org/p2> \"hello\"@en-US .\n",
|
|
|
+ "<urn:local:s1> <http://example.org/p2> \"hello\"@es-ES .\n",
|
|
|
+ "<urn:local:s1> <http://example.org/p2> _:bn1 .\n",
|
|
|
"_:bn1 <http://example.org/p1> \"hello\"@es-ES .\n",
|
|
|
"_:bn1 <http://example.org/p1> "
|
|
|
"\"25\"^^<http://www.w3.org/2001/XMLSchema#integer> .\n",
|
|
@@ -104,13 +107,13 @@ init_triples (LSUP_Term **terms)
|
|
|
{
|
|
|
memset (trp, 0, sizeof (LSUP_Triple) * 8); // Last NULL is a sentinel
|
|
|
|
|
|
- LSUP_triple_init (trp + 0, terms[0], terms[1], terms[2]);
|
|
|
- LSUP_triple_init (trp + 1, terms[0], terms[1], terms[3]);
|
|
|
- LSUP_triple_init (trp + 2, terms[0], terms[1], terms[4]);
|
|
|
- LSUP_triple_init (trp + 3, terms[0], terms[1], terms[7]);
|
|
|
- LSUP_triple_init (trp + 4, terms[7], terms[1], terms[4]);
|
|
|
- LSUP_triple_init (trp + 5, terms[7], terms[1], terms[5]);
|
|
|
- LSUP_triple_init (trp + 6, terms[7], terms[1], terms[6]);
|
|
|
+ LSUP_triple_init (trp + 0, terms[0], terms[1], terms[3]);
|
|
|
+ LSUP_triple_init (trp + 1, terms[0], terms[2], terms[4]);
|
|
|
+ LSUP_triple_init (trp + 2, terms[0], terms[2], terms[5]);
|
|
|
+ LSUP_triple_init (trp + 3, terms[0], terms[2], terms[8]);
|
|
|
+ LSUP_triple_init (trp + 4, terms[7], terms[1], terms[5]);
|
|
|
+ LSUP_triple_init (trp + 5, terms[7], terms[1], terms[6]);
|
|
|
+ LSUP_triple_init (trp + 6, terms[7], terms[1], terms[7]);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -145,10 +148,10 @@ test_encode_nt_term()
|
|
|
EXPECT_STR_EQ (out, end_nt[i]);
|
|
|
}
|
|
|
|
|
|
- EXPECT_INT_EQ (codec.encode_term (terms[8], NULL, &out), LSUP_PARSE_ERR);
|
|
|
-
|
|
|
EXPECT_INT_EQ (codec.encode_term (terms[9], NULL, &out), LSUP_PARSE_ERR);
|
|
|
|
|
|
+ EXPECT_INT_EQ (codec.encode_term (terms[10], NULL, &out), LSUP_PARSE_ERR);
|
|
|
+
|
|
|
free (out);
|
|
|
LSUP_nsmap_free (nsm);
|
|
|
free_terms(terms);
|