diff options
author | David Robillard <d@drobilla.net> | 2018-05-12 18:03:13 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-05-27 18:23:15 +0200 |
commit | f48dac14b6533b4cdd4804513216f4f11de36d9a (patch) | |
tree | a26996f7344bf67890b3004649522023b7cccfe4 /tests | |
parent | cc1378913b22737fc1abb81de15313099d005eae (diff) | |
download | serd-f48dac14b6533b4cdd4804513216f4f11de36d9a.tar.gz serd-f48dac14b6533b4cdd4804513216f4f11de36d9a.tar.bz2 serd-f48dac14b6533b4cdd4804513216f4f11de36d9a.zip |
Set datatypes on integer, decimal, and base64 nodes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/serd_test.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c index e5037945..e63e9594 100644 --- a/tests/serd_test.c +++ b/tests/serd_test.c @@ -33,6 +33,8 @@ # define NAN (INFINITY - INFINITY) #endif +#define NS_XSD "http://www.w3.org/2001/XMLSchema#" + static int test_strtod(double dbl, double max_delta) { @@ -172,7 +174,7 @@ main(void) }; for (unsigned i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) { - SerdNode* node = serd_node_new_decimal(dbl_test_nums[i], 8); + SerdNode* node = serd_node_new_decimal(dbl_test_nums[i], 8, NULL); const char* node_str = serd_node_get_string(node); const bool pass = (node_str && dbl_test_strs[i]) ? !strcmp(node_str, dbl_test_strs[i]) @@ -183,6 +185,10 @@ main(void) const size_t len = node_str ? strlen(node_str) : 0; if (serd_node_get_length(node) != len) { FAILF("Length %zu != %zu\n", serd_node_get_length(node), len); + } else if (dbl_test_strs[i] && + strcmp(serd_node_get_string(serd_node_get_datatype(node)), + NS_XSD "decimal")) { + FAIL("Decimal node has incorrect default datatype\n"); } serd_node_free(node); } @@ -198,7 +204,7 @@ main(void) }; for (unsigned i = 0; i < sizeof(int_test_nums) / sizeof(double); ++i) { - SerdNode* node = serd_node_new_integer(int_test_nums[i]); + SerdNode* node = serd_node_new_integer(int_test_nums[i], NULL); const char* node_str = serd_node_get_string(node); if (strcmp(node_str, (const char*)int_test_strs[i])) { FAILF("Serialised `%s' != %s\n", node_str, int_test_strs[i]); @@ -206,6 +212,9 @@ main(void) const size_t len = strlen(node_str); if (serd_node_get_length(node) != len) { FAILF("Length %zu,%zu != %zu\n", serd_node_get_length(node), len); + } else if (strcmp(serd_node_get_string(serd_node_get_datatype(node)), + NS_XSD "integer")) { + FAIL("Integer node has incorrect default datatype\n"); } serd_node_free(node); } @@ -218,7 +227,7 @@ main(void) } size_t out_size; - SerdNode* blob = serd_node_new_blob(data, size, size % 5); + SerdNode* blob = serd_node_new_blob(data, size, size % 5, NULL); const char* blob_str = serd_node_get_string(blob); uint8_t* out = (uint8_t*)serd_base64_decode( blob_str, serd_node_get_length(blob), &out_size); @@ -232,6 +241,11 @@ main(void) } } + if (strcmp(serd_node_get_string(serd_node_get_datatype(blob)), + NS_XSD "base64Binary")) { + FAIL("Blob node has incorrect default datatype\n"); + } + serd_node_free(blob); free(out); free(data); |