diff --git a/src/rdf_parser.c b/src/rdf_parser.c
index 5ddbf05d..93c0b59f 100644
--- a/src/rdf_parser.c
+++ b/src/rdf_parser.c
@@ -1017,7 +1017,6 @@ int main(int argc, char *argv[]);
" \"The generic home page of Dave Beckett.\" .\n" \
" \"Dave Beckett's Home Page\" . \n"
-
#define TURTLE_CONTENT \
"@prefix dc: .\n" \
"\n" \
@@ -1030,6 +1029,28 @@ int main(int argc, char *argv[]);
#define EXPECTED_TRIPLES_COUNT 3
+#define RDFXML_CONTENT_2 \
+"\n" \
+"\n" \
+" \n" \
+" Dave Beckett's Home Page\n" \
+" \n" \
+""
+
+#define NTRIPLES_CONTENT_2 \
+" \"Dave Beckett's Home Page\" . \n"
+
+#define TURTLE_CONTENT_2 \
+"@prefix dc: .\n" \
+"\n" \
+"\n" \
+" dc:title \"Dave Beckett's Home Page\" . \n"
+
+/* All the examples above give the same single triple */
+#define EXPECTED_TRIPLES_COUNT_2 1
+
+
#define URI_STRING_COUNT 3
static const char *test_parser_types[] = {
"rdfxml", "ntriples", "turtle",
@@ -1048,6 +1069,12 @@ static const unsigned char *file_content[URI_STRING_COUNT] = {
(const unsigned char*)TURTLE_CONTENT
};
+static const unsigned char *file_content_2[URI_STRING_COUNT] = {
+ (const unsigned char*)RDFXML_CONTENT_2,
+ (const unsigned char*)NTRIPLES_CONTENT_2,
+ (const unsigned char*)TURTLE_CONTENT_2
+};
+
int
main(int argc, char *argv[])
{
@@ -1073,6 +1100,7 @@ main(int argc, char *argv[])
librdf_stream *stream = NULL;
raptor_iostream *iostream = NULL;
size_t length = strlen((const char*)file_content[testi]);
+ size_t length_2 = strlen((const char*)file_content_2[testi]);
int size;
char *accept_h;
int i;
@@ -1138,11 +1166,49 @@ main(int argc, char *argv[])
}
+ /* Clear the model */
+ librdf_free_model(model);
+ model = librdf_new_model(world, storage, NULL);
+ if(!model) {
+ fprintf(stderr, "%s: Failed to create new model\n", program);
+ return(1);
+ }
+
+
+ /* Try parsing a different string, to make sure the previous one hasn't
+ * been kept in the buffer */
+ fprintf(stderr, "%s: Adding %s different counted string content as stream\n",
+ program, type);
+ stream = librdf_parser_parse_counted_string_as_stream(parser,
+ file_content_2[testi],
+ length_2,
+ uris[testi]);
+ if(!stream) {
+ fprintf(stderr,
+ "%s: Failed to parse RDF from counted string %d as stream\n",
+ program, testi);
+ failures++;
+ goto tidy_test;
+ }
+ librdf_model_add_statements(model, stream);
+ librdf_free_stream(stream);
+ stream = NULL;
+
+ size = librdf_model_size(model);
+ fprintf(stderr, "%s: Model size is %d triples\n", program, size);
+ if(size != EXPECTED_TRIPLES_COUNT_2) {
+ fprintf(stderr, "%s: Returned %d triples, not %d as expected\n",
+ program, size, EXPECTED_TRIPLES_COUNT_2);
+ failures++;
+ goto tidy_test;
+ }
+
+
+ fprintf(stderr, "%s: Adding %s string content as stream\n", program, type);
stream = librdf_parser_parse_string_as_stream(parser,
file_content[testi],
uris[testi]);
if(!stream) {
- fprintf(stderr, "%s: Adding %s string content as stream\n", program, type);
fprintf(stderr, "%s: Failed to parse RDF from string %d as stream\n",
program, testi);
failures++;