diff options
-rw-r--r-- | tests/serd_test.c | 9 | ||||
-rw-r--r-- | tests/test_utils.h | 6 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index 5ce94905..581c967a 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -214,6 +214,8 @@ main(void) } // Test serd_new_blob + CHECK(!serd_new_blob(NULL, 0, true, NULL)); + CHECK(!serd_new_blob("data", 0, true, NULL)); for (size_t size = 1; size < 256; ++size) { uint8_t* data = (uint8_t*)malloc(size); for (size_t i = 0; i < size; ++i) { @@ -351,6 +353,8 @@ main(void) FAIL("Successfully created typed literal from NULL string\n"); } + CHECK(!serd_new_typed_literal("bad type", hello)); + SerdNode* hello2 = serd_new_string("hello\""); if (serd_node_get_length(hello2) != 6 || serd_node_get_flags(hello2) != SERD_HAS_QUOTE || @@ -363,6 +367,11 @@ main(void) FAIL("Plain literal does not match equivalent string\n"); } + SerdNode* hello4 = serd_new_typed_literal("hello\"", NULL); + if (!serd_node_equals(hello4, hello2)) { + FAIL("Untyped literal does not match plain literal\n"); + } + serd_node_free(hello3); serd_node_free(hello2); diff --git a/tests/test_utils.h b/tests/test_utils.h index 815d55fd..e3bdb7ee 100644 --- a/tests/test_utils.h +++ b/tests/test_utils.h @@ -39,4 +39,10 @@ serd_test_failure(const char* fmt, ...) fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \ return serd_test_failure(fmt, __VA_ARGS__); +#define CHECK(condition) \ + if (!(condition)) { \ + fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \ + return serd_test_failure("Check `" #condition "' failed.\n"); \ + } + #endif /* SERD_TEST_UTILS_H */ |