aboutsummaryrefslogtreecommitdiff
path: root/tests/un/mathf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/un/mathf.c')
-rw-r--r--tests/un/mathf.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/un/mathf.c b/tests/un/mathf.c
index cd3a24f..2f95f40 100644
--- a/tests/un/mathf.c
+++ b/tests/un/mathf.c
@@ -276,5 +276,33 @@ int main() {
un_memory_set((void*)v, 0, sizeof(*v) * 4);
}
+ { // Complex
+ f32 v[2], a[2] = { 1, 2 }, b[2] = { 3, 4 }, c[2] = { 1, 0 }, d[3] = { 0, 1 };
+
+ un_m_complex_addf(v, a, b);
+ assert((v[0] - 4.0) < EPSILON);
+ assert((v[1] - 6.0) < EPSILON);
+ un_memory_set((void*)v, 0, sizeof(*v) * 2);
+
+ un_m_complex_subf(v, a, b);
+ assert((v[0] + 2.0) < EPSILON);
+ assert((v[1] + 2.0) < EPSILON);
+ un_memory_set((void*)v, 0, sizeof(*v) * 2);
+
+ un_m_complex_mulf(v, a, b);
+ assert((v[0] + 5.0) < EPSILON);
+ assert((v[1] - 10.0) < EPSILON);
+ un_memory_set((void*)v, 0, sizeof(*v) * 2);
+
+ un_m_complex_divf(v, c, d);
+ assert(v[0] < EPSILON);
+ assert((v[1] + 1.0) < EPSILON);
+ un_memory_set((void*)v, 0, sizeof(*v) * 2);
+
+ un_m_complex_magnitudef(v, c);
+ assert((v[0] - 1.0) < EPSILON);
+ un_memory_set((void*)v, 0, sizeof(*v) * 2);
+ }
+
return 0;
}