diff options
author | David Robillard <d@drobilla.net> | 2020-08-14 16:05:10 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:24 -0500 |
commit | 6f03ae92415a7758fdc74f6720ec4955bc67fc0c (patch) | |
tree | 027582bca0844f8fe650db707eb14dc3b46c7598 /test/test_node.c | |
parent | 194d6f42583745c3fde6387b14abab2311b4f0b7 (diff) | |
download | serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.tar.gz serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.tar.bz2 serd-6f03ae92415a7758fdc74f6720ec4955bc67fc0c.zip |
Merge datatype/language into node
This moves closer to the sord API, and is more convenient in most cases.
Diffstat (limited to 'test/test_node.c')
-rw-r--r-- | test/test_node.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_node.c b/test/test_node.c index be3576ff..00a24b99 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -194,6 +194,37 @@ test_node_from_substring(void) serd_node_free(a_b); } +static void +test_literal(void) +{ + SerdNode* hello2 = serd_new_literal("hello\"", NULL, NULL); + assert(serd_node_length(hello2) == 6 && + serd_node_flags(hello2) == SERD_HAS_QUOTE && + !strcmp(serd_node_string(hello2), "hello\"")); + serd_node_free(hello2); + + SerdNode* hello_l = serd_new_literal("hello_l\"", NULL, "en"); + assert(serd_node_length(hello_l) == 8); + assert(!strcmp(serd_node_string(hello_l), "hello_l\"")); + assert(serd_node_flags(hello_l) == (SERD_HAS_QUOTE | SERD_HAS_LANGUAGE)); + + const SerdNode* const lang = serd_node_language(hello_l); + assert(lang); + assert(!strcmp(serd_node_string(lang), "en")); + serd_node_free(hello_l); + + SerdNode* hello_dt = + serd_new_literal("hello_dt\"", "http://example.org/Thing", NULL); + assert(serd_node_length(hello_dt) == 9); + assert(!strcmp(serd_node_string(hello_dt), "hello_dt\"")); + assert(serd_node_flags(hello_dt) == (SERD_HAS_QUOTE | SERD_HAS_DATATYPE)); + + const SerdNode* const datatype = serd_node_datatype(hello_dt); + assert(datatype); + assert(!strcmp(serd_node_string(datatype), "http://example.org/Thing")); + serd_node_free(hello_dt); +} + int main(void) { @@ -204,6 +235,7 @@ main(void) test_node_equals(); test_node_from_string(); test_node_from_substring(); + test_literal(); printf("Success\n"); return 0; |