Martin Storsjo : msvcrt: Add hyperbolic functions NAN tests.

Alexandre Julliard julliard at winehq.org
Wed Jul 28 15:37:42 CDT 2021


Module: wine
Branch: master
Commit: 868c9ee7c92a528461fc1d00d30e75dbb85958bb
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=868c9ee7c92a528461fc1d00d30e75dbb85958bb

Author: Martin Storsjo <martin at martin.st>
Date:   Wed Jul 28 14:42:24 2021 +0200

msvcrt: Add hyperbolic functions NAN tests.

Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/tests/misc.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/dlls/msvcrt/tests/misc.c b/dlls/msvcrt/tests/misc.c
index b38915596df..81c23dd23f2 100644
--- a/dlls/msvcrt/tests/misc.c
+++ b/dlls/msvcrt/tests/misc.c
@@ -491,8 +491,35 @@ static void test_qsort_s(void)
         ok(tab[i] == i, "data sorted incorrectly on position %d: %d\n", i, tab[i]);
 }
 
+static int eq_nan(UINT64 ai, double b)
+{
+    UINT64 bi = *(UINT64*)&b;
+    UINT64 mask;
+
+#if defined(__i386__)
+    mask = 0xFFFFFFFF00000000ULL;
+#else
+    mask = ~0;
+#endif
+
+    ok((ai & mask) == (bi & mask), "comparing %s and %s\n",
+            wine_dbgstr_longlong(ai), wine_dbgstr_longlong(bi));
+    return (ai & mask) == (bi & mask);
+}
+
+static int eq_nanf(DWORD ai, float b)
+{
+    DWORD bi = *(DWORD*)&b;
+    ok(ai == bi, "comparing %08x and %08x\n", ai, bi);
+    return ai == bi;
+}
+
 static void test_math_functions(void)
 {
+    static const UINT64 test_nan_i = 0xFFF0000123456780ULL;
+    static const DWORD test_nanf_i = 0xFF801234;
+    double test_nan = *(double*)&test_nan_i;
+    float test_nanf = *(float*)&test_nanf_i;
     double ret;
 
     errno = 0xdeadbeef;
@@ -525,6 +552,13 @@ static void test_math_functions(void)
     errno = 0xdeadbeef;
     p_exp(INFINITY);
     ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+    ok(eq_nan(test_nan_i | (1ULL << 51), cosh(test_nan)), "cosh not preserving nan\n");
+    ok(eq_nan(test_nan_i | (1ULL << 51), sinh(test_nan)), "sinh not preserving nan\n");
+    ok(eq_nan(test_nan_i | (1ULL << 51), tanh(test_nan)), "tanh not preserving nan\n");
+    ok(eq_nanf(test_nanf_i | (1 << 22), coshf(test_nanf)), "coshf not preserving nan\n");
+    ok(eq_nanf(test_nanf_i | (1 << 22), sinhf(test_nanf)), "sinhf not preserving nan\n");
+    ok(eq_nanf(test_nanf_i | (1 << 22), tanhf(test_nanf)), "tanhf not preserving nan\n");
 }
 
 static void __cdecl test_thread_func(void *end_thread_type)




More information about the wine-cvs mailing list