aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-07 23:50:39 -0400
committerDavid Robillard <d@drobilla.net>2018-11-25 09:21:03 +0100
commit6d57362026dcd33f6502b968cee57851d16ee665 (patch)
tree222cd479575a1daab4d2aaa84a4a42e0f3c1c071 /tests
parent9e9ef4bb215594d607ae146d2fdc17adbfcdd4cc (diff)
downloadserd-6d57362026dcd33f6502b968cee57851d16ee665.tar.gz
serd-6d57362026dcd33f6502b968cee57851d16ee665.tar.bz2
serd-6d57362026dcd33f6502b968cee57851d16ee665.zip
Make serd_strtod API const-correct
This is an API breakage, but a minor one (particularly since NULL is allowed) that avoids the flaw in the C API.
Diffstat (limited to 'tests')
-rw-r--r--tests/serd_test.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 8a91ab42..a8d17349 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -38,13 +38,18 @@ test_strtod(double dbl, double max_delta)
char buf[1024];
snprintf(buf, sizeof(buf), "%f", dbl);
- char* endptr = NULL;
- const double out = serd_strtod(buf, &endptr);
+ size_t end = 0;
+ const double out = serd_strtod(buf, &end);
const double diff = fabs(out - dbl);
if (diff > max_delta) {
FAILF("Parsed %lf != %lf (delta %lf)\n", dbl, out, diff);
}
+
+ if (end != strlen(buf)) {
+ FAILF("Parsed %lf length %zu != %zu\n", end, strlen(buf));
+ }
+
return 0;
}