From 203ca287b9fe7dc00f02ac5e354260cfedfeac93 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 30 Sep 2020 10:53:19 +0200 Subject: Add a test for reading strings with no trailing newline --- tests/serd_test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/serd_test.c b/tests/serd_test.c index 05fb0461..efb38161 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -187,6 +187,28 @@ test_read_chunks(void) fclose(f); } +static void +test_read_string(void) +{ + ReaderTest* rt = (ReaderTest*)calloc(1, sizeof(ReaderTest)); + SerdReader* reader = serd_reader_new( + SERD_TURTLE, rt, free, + NULL, NULL, test_sink, NULL); + assert(reader); + assert(serd_reader_get_handle(reader) == rt); + + // Test reading a string that ends exactly at the end of input (no newline) + const SerdStatus st = + serd_reader_read_string(reader, + USTR(" " + " .")); + + assert(!st); + assert(rt->n_statements == 1); + + serd_reader_free(reader); +} + static void test_string_to_double(void) { @@ -654,6 +676,7 @@ main(void) test_uri_from_string(); test_relative_uri(); test_read_chunks(); + test_read_string(); const char* const path = "serd_test.ttl"; test_writer(path); -- cgit v1.2.1