aboutsummaryrefslogtreecommitdiffstats
path: root/tests/serd_test.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-14 18:39:36 +0200
committerDavid Robillard <d@drobilla.net>2020-08-14 19:07:52 +0200
commit64c9584f174f4161963d1e756e4cfadce5793d69 (patch)
treeb9fcfd0ed967793eefd942be9a8aa31d278b7206 /tests/serd_test.c
parentbc01889ccdfff3b39a93a537c9e92745d327e5da (diff)
downloadserd-64c9584f174f4161963d1e756e4cfadce5793d69.tar.gz
serd-64c9584f174f4161963d1e756e4cfadce5793d69.tar.bz2
serd-64c9584f174f4161963d1e756e4cfadce5793d69.zip
Avoid use of rand()
Diffstat (limited to 'tests/serd_test.c')
-rw-r--r--tests/serd_test.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index fbc42bcd..15500a0e 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -173,15 +173,6 @@ test_read_chunks(void)
static void
test_string_to_double(void)
{
-#define MAX 1000000
-#define NUM_TESTS 1000
- for (int i = 0; i < NUM_TESTS; ++i) {
- double dbl = rand() % MAX;
- dbl += (rand() % MAX) / (double)MAX;
-
- test_strtod(dbl, 1 / (double)MAX);
- }
-
const double expt_test_nums[] = {
2.0E18, -5e19, +8e20, 2e+24, -5e-5, 8e0, 9e-0, 2e+0
};
@@ -194,6 +185,8 @@ test_string_to_double(void)
const double num = serd_strtod(expt_test_strs[i], NULL);
const double delta = fabs(num - expt_test_nums[i]);
assert(delta <= DBL_EPSILON);
+
+ test_strtod(expt_test_nums[i], DBL_EPSILON);
}
}
@@ -246,7 +239,7 @@ test_blob_to_node(void)
for (size_t size = 0; size < 256; ++size) {
uint8_t* data = size > 0 ? (uint8_t*)malloc(size) : NULL;
for (size_t i = 0; i < size; ++i) {
- data[i] = (uint8_t)(rand() % 256);
+ data[i] = (uint8_t)((size + i) % 256);
}
SerdNode blob = serd_node_new_blob(data, size, size % 5);