From b5fd72d61a99608a6c6c17e59016afd125782d27 Mon Sep 17 00:00:00 2001
From: David Robillard <d@drobilla.net>
Date: Mon, 9 Nov 2020 19:34:03 +0100
Subject: Add a test for reading strings with no trailing newline

---
 test/test_reader_writer.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 3bedb95e..60f8805f 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -140,6 +140,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("<http://example.org/s> <http://example.org/p> "
+		                             "<http://example.org/o> ."));
+
+	assert(!st);
+	assert(rt->n_statements == 1);
+
+	serd_reader_free(reader);
+}
+
 static void
 test_writer(const char* const path)
 {
@@ -319,6 +341,7 @@ int
 main(void)
 {
 	test_read_chunks();
+	test_read_string();
 
 	const char* const path = "serd_test.ttl";
 	test_writer(path);
-- 
cgit v1.2.1