From ffcb15d3f25ebc25ee0dab68fadfe5e88e2b755f Mon Sep 17 00:00:00 2001 From: dizcza Date: Sat, 8 Aug 2020 21:07:10 +0200 Subject: added tests --- linmath_test.h | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 linmath_test.h (limited to 'linmath_test.h') diff --git a/linmath_test.h b/linmath_test.h new file mode 100644 index 0000000..5c48444 --- /dev/null +++ b/linmath_test.h @@ -0,0 +1,242 @@ +/* + * linmath_test.h + * + * Created on: Apr 9, 2017 + * Author: Danylo Ulianych + */ + +#ifndef LINMATH_TEST_H +#define LINMATH_TEST_H + +#include +#include "linmath.h" + +#define LINMATH_EPS (0.0001f) +#define linmath_is_close(val1, val2) (fabsf(val1 - val2) < LINMATH_EPS) + +#ifndef linmath_assert +#include +#define linmath_assert assert +#endif /* linmath_assert */ + + +static float linmath_random_float() { + return rand() / (float) RAND_MAX; +} + +#define LINMATH_TEST_DEFINE_VEC(n) \ +static void linmath_vec##n##_set(vec##n v, float value) { \ + int i; \ + for (i=0; i