summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-09-16 00:55:35 -0500
committersanine <sanine.not@pm.me>2022-09-16 00:55:35 -0500
commitf2eb020c4199134e07632f3c6690d68381837b85 (patch)
treed1bd4ae78f405b79f75d5af3ddf4b38b3b6a2b4b /src
parent8abd7a81c988b26c19406c1ea669e050d56d2db5 (diff)
fix bug in float assertions
Diffstat (limited to 'src')
-rw-r--r--src/test/honey-test.h2
-rw-r--r--src/test/lily-test.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/src/test/honey-test.h b/src/test/honey-test.h
index 03218a4..a864881 100644
--- a/src/test/honey-test.h
+++ b/src/test/honey-test.h
@@ -32,11 +32,13 @@ void suite_logging();
void suite_gl();
void suite_window();
void suite_util();
+void suite_import();
#define RUN_TESTS() \
lily_run_suite(suite_logging); \
lily_run_suite(suite_gl); \
lily_run_suite(suite_window); \
lily_run_suite(suite_util); \
+ lily_run_suite(suite_import); \
#endif
diff --git a/src/test/lily-test.c b/src/test/lily-test.c
index 2f43a28..30f96d5 100644
--- a/src/test/lily-test.c
+++ b/src/test/lily-test.c
@@ -47,6 +47,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <math.h>
#include "lily-test.h"
struct lily_globals_t _lily_globals = { {0}, 0, NULL, "" };
@@ -209,7 +210,7 @@ void _lily_assert_int_not_equal(const char *name_a, const char *name_b,
void _lily_assert_float_equal(const char *name_a, const char *name_b,
double a, double b, double epsilon, const char *location)
{
- lily_assert_msg(abs(a - b) <= epsilon,
+ lily_assert_msg(fabs(a - b) <= epsilon, location,
"%s (%f) is not equal to %s (%f) (epsilon: %f)",
name_a, a, name_b, b, epsilon);
}
@@ -218,7 +219,7 @@ void _lily_assert_float_equal(const char *name_a, const char *name_b,
void _lily_assert_float_not_equal(const char *name_a, const char *name_b,
double a, double b, double epsilon, const char *location)
{
- lily_assert_msg(abs(a - b) > epsilon,
+ lily_assert_msg(fabs(a - b) > epsilon, location,
"%s (%f) is equal to %s (%f) (epsilon: %f)",
name_a, a, name_b, b, epsilon);
}
@@ -227,7 +228,7 @@ void _lily_assert_float_not_equal(const char *name_a, const char *name_b,
void _lily_assert_string_equal(const char *name_a, const char *name_b,
char *a, char *b, const char *location)
{
- lily_assert_msg(strcmp(a, b) == 0,
+ lily_assert_msg(strcmp(a, b) == 0, location,
"%s ('%s') is not equal to %s ('%s')",
name_a, a, name_b, b);
}
@@ -236,7 +237,7 @@ void _lily_assert_string_equal(const char *name_a, const char *name_b,
void _lily_assert_string_not_equal(const char *name_a, const char *name_b,
char *a, char *b, const char *location)
{
- lily_assert_msg(strcmp(a, b) != 0,
+ lily_assert_msg(strcmp(a, b) != 0, location,
"%s ('%s') is equal to %s",
name_a, a, name_b);
}
@@ -245,7 +246,7 @@ void _lily_assert_string_not_equal(const char *name_a, const char *name_b,
void _lily_assert_memory_equal(const char *name_a, const char *name_b,
void *a, void *b, size_t size, const char *location)
{
- lily_assert_msg(memcmp(a, b, size) == 0,
+ lily_assert_msg(memcmp(a, b, size) == 0, location,
"%s and %s contain different data", name_a, name_b);
}
@@ -253,7 +254,7 @@ void _lily_assert_memory_equal(const char *name_a, const char *name_b,
void _lily_assert_memory_not_equal(const char *name_a, const char *name_b,
void *a, void *b, size_t size, const char *location)
{
- lily_assert_msg(memcmp(a, b, size) == 0,
+ lily_assert_msg(memcmp(a, b, size) == 0, location,
"%s contains the same data s %s", name_a, name_b);
}