diff options
author | bonmas14 <bonmas14@gmail.com> | 2025-08-23 01:28:41 +0300 |
---|---|---|
committer | bonmas14 <bonmas14@gmail.com> | 2025-08-23 01:28:41 +0300 |
commit | 8ebdc95621bc61fdf3c98cd7ae4ddca67398df23 (patch) | |
tree | 205413ed09ac001e37267889d429a363c37008f2 /tests/un/mathf.c | |
parent | c96c355b360f18f982459e1a866dcbf5864efdb8 (diff) | |
download | ungrateful-8ebdc95621bc61fdf3c98cd7ae4ddca67398df23.tar.gz ungrateful-8ebdc95621bc61fdf3c98cd7ae4ddca67398df23.zip |
Diffstat (limited to 'tests/un/mathf.c')
-rw-r--r-- | tests/un/mathf.c | 28 |
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; } |