diff options
author | David Robillard <d@drobilla.net> | 2021-03-01 17:57:54 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-01-13 23:03:41 -0500 |
commit | f074a83f20e04e360704a190ab5f4e646f4272b7 (patch) | |
tree | 712d4c32c10c8273f866f0cc297cae232d43d9bd /test | |
parent | dcff19f69bb5cbd718d507e7af6814b997bc4c3f (diff) | |
download | serd-f074a83f20e04e360704a190ab5f4e646f4272b7.tar.gz serd-f074a83f20e04e360704a190ab5f4e646f4272b7.tar.bz2 serd-f074a83f20e04e360704a190ab5f4e646f4272b7.zip |
Clean up nodes in reader/writer tests
Diffstat (limited to 'test')
-rw-r--r-- | test/test_reader_writer.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c index 730e5bf0..7a9cc390 100644 --- a/test/test_reader_writer.c +++ b/test/test_reader_writer.c @@ -203,24 +203,28 @@ test_writer(const char* const path) assert(serd_sink_write_prefix(iface, lit, lit)); assert(serd_sink_write_end(iface, lit)); - static const uint8_t buf[] = {0xEF, 0xBF, 0xBD, 0}; - const SerdStringView buf_view = {(const char*)buf, 3}; + static const uint8_t bad_buf[] = {0xEF, 0xBF, 0xBD, 0}; + const SerdStringView bad_buf_view = {(const char*)bad_buf, 3}; - SerdNode* s = serd_new_uri(SERD_EMPTY_STRING()); - SerdNode* p = serd_new_uri(SERD_STRING("http://example.org/pred")); - SerdNode* o = serd_new_string(buf_view); + SerdNode* s = serd_new_uri(SERD_STRING("http://example.org")); + SerdNode* p = serd_new_uri(SERD_STRING("http://example.org/pred")); + SerdNode* bad = serd_new_string(bad_buf_view); // Write 3 invalid statements (should write nothing) - const SerdNode* junk[][3] = {{s, o, o}, {o, p, o}, {s, o, p}}; + const SerdNode* junk[][3] = {{s, bad, bad}, {bad, p, bad}, {s, bad, p}}; for (size_t i = 0; i < sizeof(junk) / (sizeof(SerdNode*) * 3); ++i) { assert(serd_sink_write(iface, 0, junk[i][0], junk[i][1], junk[i][2], NULL)); } + serd_node_free(bad); + static const SerdStringView urn_Type = SERD_STRING("urn:Type"); static const SerdStringView en = SERD_STRING("en"); - SerdNode* const t = serd_new_typed_literal(buf_view, urn_Type); - SerdNode* const l = serd_new_plain_literal(buf_view, en); + SerdNode* const o = serd_new_string(SERD_STRING("o")); + SerdNode* const t = serd_new_typed_literal(SERD_STRING("t"), urn_Type); + SerdNode* const l = serd_new_plain_literal(SERD_STRING("l"), en); + const SerdNode* good[][3] = {{s, p, o}, {s, p, t}, {s, p, l}}; for (size_t i = 0; i < sizeof(good) / (sizeof(SerdNode*) * 3); ++i) { @@ -228,11 +232,14 @@ test_writer(const char* const path) !serd_sink_write(iface, 0, good[i][0], good[i][1], good[i][2], NULL)); } + static const uint8_t bad_str_buf[] = {0xFF, 0x90, 'h', 'i', 0}; + static const uint8_t bad_uri_buf[] = {'f', 't', 'p', ':', 0xFF, 0x90, 0}; + static const char* const bad_lit_str = (const char*)bad_str_buf; + static const char* const bad_uri_str = (const char*)bad_uri_buf; + // Write statements with bad UTF-8 (should be replaced) - const char bad_str[] = {(char)0xFF, (char)0x90, 'h', 'i', 0}; - const SerdStringView bad_view = {(const char*)bad_str, 4}; - SerdNode* bad_lit = serd_new_string(bad_view); - SerdNode* bad_uri = serd_new_uri(bad_view); + SerdNode* bad_lit = serd_new_string(SERD_STRING(bad_lit_str)); + SerdNode* bad_uri = serd_new_uri(SERD_STRING(bad_uri_str)); assert(!serd_sink_write(iface, 0, s, p, bad_lit, 0)); assert(!serd_sink_write(iface, 0, s, p, bad_uri, 0)); serd_node_free(bad_uri); @@ -244,6 +251,7 @@ test_writer(const char* const path) serd_node_free(hello); serd_writer_free(writer); + serd_node_free(lit); serd_node_free(o); serd_node_free(t); |