aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-12 18:03:13 +0200
committerDavid Robillard <d@drobilla.net>2018-12-30 17:58:17 -0500
commit2b0e3de607f2b0eca00b3986ecbcd9fe26ecf95d (patch)
treee2574e8e816bcef8fae80538123f3a3b386a30eb /tests
parentf539637ea4dc40a8a2552f15092ea3abd69d5343 (diff)
downloadserd-2b0e3de607f2b0eca00b3986ecbcd9fe26ecf95d.tar.gz
serd-2b0e3de607f2b0eca00b3986ecbcd9fe26ecf95d.tar.bz2
serd-2b0e3de607f2b0eca00b3986ecbcd9fe26ecf95d.zip
Set datatypes on integer, decimal, and base64 nodes
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index dbadb5bf..0187b868 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -34,6 +34,8 @@
# define NAN (INFINITY - INFINITY)
#endif
+#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
+
static int
test_strtod(double dbl, double max_delta)
{
@@ -179,13 +181,17 @@ 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])
: (node_str == dbl_test_strs[i]);
assert(pass);
- assert(serd_node_get_length(node) == (node_str ? strlen(node_str) : 0));
+ const size_t len = node_str ? strlen(node_str) : 0;
+ assert(serd_node_get_length(node) == len);
+ assert(!dbl_test_strs[i] ||
+ !strcmp(serd_node_get_string(serd_node_get_datatype(node)),
+ NS_XSD "decimal"));
serd_node_free(node);
}
@@ -200,10 +206,13 @@ 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);
assert(!strcmp(node_str, int_test_strs[i]));
- assert(serd_node_get_length(node) == strlen(node_str));
+ const size_t len = strlen(node_str);
+ assert(serd_node_get_length(node) == len);
+ assert(!strcmp(serd_node_get_string(serd_node_get_datatype(node)),
+ NS_XSD "integer"));
serd_node_free(node);
}
@@ -215,7 +224,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);
@@ -227,6 +236,9 @@ main(void)
assert(out[i] == data[i]);
}
+ assert(!strcmp(serd_node_get_string(serd_node_get_datatype(blob)),
+ NS_XSD "base64Binary"));
+
serd_node_free(blob);
serd_free(out);
free(data);