diff options
author | David Robillard <d@drobilla.net> | 2020-11-09 19:34:03 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-09 20:03:10 +0100 |
commit | b5fd72d61a99608a6c6c17e59016afd125782d27 (patch) | |
tree | 07b31e199b3fcceae219912e6d66d87bbdf230ab /test | |
parent | 6bd53f582297574cf009ff0cfd80a1fd3a315b6b (diff) | |
download | serd-b5fd72d61a99608a6c6c17e59016afd125782d27.tar.gz serd-b5fd72d61a99608a6c6c17e59016afd125782d27.tar.bz2 serd-b5fd72d61a99608a6c6c17e59016afd125782d27.zip |
Add a test for reading strings with no trailing newline
Diffstat (limited to 'test')
-rw-r--r-- | test/test_reader_writer.c | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ -141,6 +141,28 @@ test_read_chunks(void) } 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) { FILE* fd = fopen(path, "wb"); @@ -319,6 +341,7 @@ int main(void) { test_read_chunks(); + test_read_string(); const char* const path = "serd_test.ttl"; test_writer(path); |