aboutsummaryrefslogtreecommitdiff
path: root/tests/un/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/un/math.c')
-rw-r--r--tests/un/math.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/un/math.c b/tests/un/math.c
index 6cc7cd8..eab0dcb 100644
--- a/tests/un/math.c
+++ b/tests/un/math.c
@@ -1,5 +1,37 @@
#include <ungrateful.h>
-int main(void) {
+int main() {
+ // Lerping
+ {
+ f64 d;
+ real r;
+ f32 f;
+
+ r = un_m_lerpr(1.0f, 2.0f, 0.5f);
+ assert(fabs(r - 1.5f) < EPSILON);
+
+ f = un_m_lerpf(1.0f, 2.0f, 0.5f);
+ assert(fabsf(f - 1.5f) < EPSILON);
+
+ d = un_m_lerpd(1.0, 2.0, 0.5);
+ assert(fabs(d - 1.5) < 0.000001);
+ }
+ // Test Bezier curve functions
+ {
+ f64 d;
+ real r;
+ f32 f;
+
+ un_m_bezierf(&f, 0.0f, 1.0f, 2.0f, 3.0f, 0.5f);
+ assert(fabsf(f - 1.5f) < EPSILON);
+
+ un_m_bezierd(&d, 0.0, 1.0, 2.0, 3.0, 0.5);
+ assert(fabs(d - 1.5) < EPSILON);
+
+ un_m_bezierr(&r, 0.0, 1.0, 2.0, 3.0, 0.5);
+ assert(fabs(r - 1.5) < EPSILON);
+ }
+
+ return 0;
}