aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-10-06 21:27:13 +0200
committerDavid Robillard <d@drobilla.net>2020-06-21 18:12:04 +0200
commit1b545eb4d79d20906f2d024f7b8e794e7cd305a7 (patch)
treeab42783108871b66d0ecf27a78cd23fb98d0e4f1
parent8eb706747dafe8aa72cba2ac9588ae4a16a1e8d3 (diff)
downloadserd-1b545eb4d79d20906f2d024f7b8e794e7cd305a7.tar.gz
serd-1b545eb4d79d20906f2d024f7b8e794e7cd305a7.tar.bz2
serd-1b545eb4d79d20906f2d024f7b8e794e7cd305a7.zip
Remove old floating point tests
-rw-r--r--tests/serd_test.c103
1 files changed, 0 insertions, 103 deletions
diff --git a/tests/serd_test.c b/tests/serd_test.c
index 64c4530b..66a9d212 100644
--- a/tests/serd_test.c
+++ b/tests/serd_test.c
@@ -19,37 +19,14 @@
#include "serd/serd.h"
#include <assert.h>
-#include <float.h>
-#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef INFINITY
-# define INFINITY (DBL_MAX + DBL_MAX)
-#endif
-#ifndef NAN
-# define NAN (INFINITY - INFINITY)
-#endif
-
#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
-static void
-test_strtod(double dbl, double max_delta)
-{
- char buf[1024];
- snprintf(buf, sizeof(buf), "%f", dbl);
-
- size_t end = 0;
- const double out = serd_strtod(buf, &end);
-
- const double diff = fabs(out - dbl);
- assert(diff <= max_delta);
- assert(end == strlen(buf));
-}
-
static SerdStatus
count_prefixes(void* handle, const SerdNode* name, const SerdNode* uri)
{
@@ -244,84 +221,6 @@ test_strict_write(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);
- }
-
- size_t end = 0;
- assert(isnan(serd_strtod("NaN", &end)));
- assert(end == 3);
-
- assert(serd_strtod("INF", &end) == INFINITY);
- assert(end == 3);
-
- assert(serd_strtod("-INF", &end) == -INFINITY);
- assert(end == 4);
-
- const double expt_test_nums[] = {
- 2.0E18, -5e19, +8e20, 2e+24, -5e-5, 8e0, 9e-0, 2e+0
- };
-
- const char* expt_test_strs[] = {
- "02e18", "-5e019", "+8e20", "2E+24", "-5E-5", "8E0", "9e-0", " 2e+0"
- };
-
- for (unsigned i = 0; i < sizeof(expt_test_nums) / sizeof(double); ++i) {
- const double num = serd_strtod(expt_test_strs[i], NULL);
- const double delta = fabs(num - expt_test_nums[i]);
- assert(delta <= DBL_EPSILON);
- }
-}
-
-static void
-test_double_to_node(void)
-{
- const double dbl_test_nums[] = { 0.0,
- 9.0,
- 10.0,
- .01,
- 2.05,
- -16.00001,
- 5.000000005,
- 0.0000000001,
- (double)NAN,
- (double)INFINITY };
-
- const char* dbl_test_strs[] = { "0.0",
- "9.0",
- "10.0",
- "0.01",
- "2.05",
- "-16.00001",
- "5.0",
- "0.0",
- NULL,
- NULL };
-
- for (size_t i = 0; i < sizeof(dbl_test_nums) / sizeof(double); ++i) {
- SerdNode* node = serd_new_decimal(dbl_test_nums[i], 17, 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);
- 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);
- }
-}
-
-static void
test_integer_to_node(void)
{
const long int_test_nums[] = {
@@ -920,8 +819,6 @@ test_reader(const char* path)
int
main(void)
{
- test_string_to_double();
- test_double_to_node();
test_integer_to_node();
test_blob_to_node();
test_boolean();