https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a2e9dcf0a709982af739e…
commit a2e9dcf0a709982af739e895b27623f70f77d56b
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Thu Sep 9 01:14:44 2021 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Thu Sep 9 16:02:11 2021 +0300
[CRT_APITEST] Add tests for __i64tod/u64tod/i64tos/u64tos on ARM (#3866)
CORE-17713 CORE-17706 CORE-17604
---
modules/rostests/apitests/crt/__64tof.c | 130 +++++++++++++++++++++
.../rostests/apitests/crt/msvcrt_crt_apitest.cmake | 1 +
.../rostests/apitests/crt/static_crt_apitest.cmake | 1 +
modules/rostests/apitests/crt/testlist.c | 2 +
4 files changed, 134 insertions(+)
diff --git a/modules/rostests/apitests/crt/__64tof.c
b/modules/rostests/apitests/crt/__64tof.c
new file mode 100644
index 00000000000..224df034699
--- /dev/null
+++ b/modules/rostests/apitests/crt/__64tof.c
@@ -0,0 +1,130 @@
+/*
+ * PROJECT: ReactOS API tests
+ * LICENSE: GPL-2.0-or-later (
https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE: Tests for __i64tod/u64tod/i64tos/u64tos on ARM
+ * COPYRIGHT: Copyright 2021 Stanislav Motylkov <x86corez(a)gmail.com>
+ */
+
+#include <apitest.h>
+
+typedef struct _I64TOD_TEST_DATA
+{
+ long long given;
+ union
+ {
+ double value;
+ unsigned long long raw;
+ } expected;
+} I64TOD_TEST_DATA;
+
+typedef struct _U64TOD_TEST_DATA
+{
+ unsigned long long given;
+ union
+ {
+ double value;
+ unsigned long long raw;
+ } expected;
+} U64TOD_TEST_DATA;
+
+typedef struct _I64TOS_TEST_DATA
+{
+ long long given;
+ union
+ {
+ float value;
+ unsigned int raw;
+ } expected;
+} I64TOS_TEST_DATA;
+
+typedef struct _U64TOS_TEST_DATA
+{
+ unsigned long long given;
+ union
+ {
+ float value;
+ unsigned int raw;
+ } expected;
+} U64TOS_TEST_DATA;
+
+START_TEST(__64tof)
+{
+ I64TOD_TEST_DATA i64tod[] =
+ {
+ { 1383034209LL, 1383034209.0 }, /* test 32bit number */
+ { -1383034209LL, -1383034209.0 }, /* test negative 32bit number */
+ { 354056757614LL, 354056757614.0 }, /* test 64bit int */
+ { -354056757614LL, -354056757614.0 }, /* test negative 64bit int */
+ { 18446744073709550000LL, -1616.0 }, /* test 20bit in float */
+ { 0x8000000000000000LL, -9223372036854775800.0 }, /* test big 64bit int */
+ { 0xFFFFFFFFFFFFFFFFLL, -1.0 }, /* test -1 */
+ { 0LL, +0.0 }, /* test 0 */
+ };
+ U64TOD_TEST_DATA u64tod[] =
+ {
+ { 1383034209ULL, 1383034209.0 }, /* test 32bit number */
+ { 354056757614ULL, 354056757614.0 }, /* test 64bit int */
+ { 18445937028656326656ULL, 18445937028656326656.0 }, /* test unsigned 64bit */
+ { 18446744073709550000ULL, 18446744073709550000.0 }, /* test 20bit in float */
+ { 18446744073709551615ULL, 18446744073709552000.0 }, /* test big 64bit number */
+ { 0ULL, +0.0 }, /* test 0 */
+ };
+ I64TOS_TEST_DATA i64tos[] =
+ {
+ { 1383034LL, 1383034.0f }, /* test 32bit number */
+ { -1383034LL, -1383034.0f }, /* test negative 32bit number */
+ { 354056765440LL, 354056765440.0f }, /* test 64bit int */
+ { -354056765440LL, -354056765440.0f }, /* test negative 64bit int */
+ { 18446744073709550000LL, -1616.0f }, /* test 20bit in float */
+ { 0x8000000000000000LL, -9223372036854775800.0f }, /* test big 64bit int */
+ { 0xFFFFFFFFFFFFFFFFLL, -1.0f }, /* test -1 */
+ { 0LL, +0.0f }, /* test 0 */
+ };
+ U64TOS_TEST_DATA u64tos[] =
+ {
+ { 1383034ULL, 1383034.0f }, /* test 32bit number */
+ { 354056765440ULL, 354056765440.0f }, /* test 64bit int */
+ { 18445937032174764032ULL, 18445937032174764032.0f }, /* test unsigned 64bit */
+ { 18446744073709550000ULL, 18446744073709550000.0f }, /* test 20bit in float */
+ { 18446744073709551615ULL, 18446744073709552000.0f }, /* test big 64bit number
*/
+ { 0ULL, +0.0f }, /* test 0 */
+ };
+
+ unsigned int i;
+
+ for (i = 0; i < _countof(i64tod); ++i)
+ {
+ double actual;
+
+ actual = (double)i64tod[i].given;
+ ok(actual == i64tod[i].expected.value, "(i64tod) %d: Expected %lf, but %lld
-> %lf\n",
+ i, i64tod[i].expected.value, i64tod[i].given, actual);
+ }
+
+ for (i = 0; i < _countof(u64tod); ++i)
+ {
+ double actual;
+
+ actual = (double)u64tod[i].given;
+ ok(actual == u64tod[i].expected.value, "(u64tod) %d: Expected %lf, but %llu
-> %lf\n",
+ i, u64tod[i].expected.value, u64tod[i].given, actual);
+ }
+
+ for (i = 0; i < _countof(i64tos); ++i)
+ {
+ float actual;
+
+ actual = (float)i64tos[i].given;
+ ok(actual == i64tos[i].expected.value, "(i64tos) %d: Expected %f, but %lld
-> %f\n",
+ i, i64tos[i].expected.value, i64tos[i].given, actual);
+ }
+
+ for (i = 0; i < _countof(u64tos); ++i)
+ {
+ float actual;
+
+ actual = (float)u64tos[i].given;
+ ok(actual == u64tos[i].expected.value, "(u64tos) %d: Expected %f, but %llu
-> %f\n",
+ i, u64tos[i].expected.value, u64tos[i].given, actual);
+ }
+}
diff --git a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
index dcef3b0d582..82283e5a3a6 100644
--- a/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
+++ b/modules/rostests/apitests/crt/msvcrt_crt_apitest.cmake
@@ -1376,6 +1376,7 @@ elseif(ARCH STREQUAL "arm")
list(APPEND SOURCE_MSVCRT
__rt_div.c
__fto64.c
+ __64tof.c
)
endif()
diff --git a/modules/rostests/apitests/crt/static_crt_apitest.cmake
b/modules/rostests/apitests/crt/static_crt_apitest.cmake
index 17ff8f8d733..a3e35c412b3 100644
--- a/modules/rostests/apitests/crt/static_crt_apitest.cmake
+++ b/modules/rostests/apitests/crt/static_crt_apitest.cmake
@@ -30,6 +30,7 @@ elseif(ARCH STREQUAL "arm")
list(APPEND SOURCE_STATIC
__rt_div.c
__fto64.c
+ __64tof.c
)
endif()
diff --git a/modules/rostests/apitests/crt/testlist.c
b/modules/rostests/apitests/crt/testlist.c
index 1997603fbca..e8b4c7670fb 100644
--- a/modules/rostests/apitests/crt/testlist.c
+++ b/modules/rostests/apitests/crt/testlist.c
@@ -12,6 +12,7 @@ extern void func_atexit(void);
#if defined(_M_ARM)
extern void func___rt_div(void);
extern void func___fto64(void);
+extern void func___64tof(void);
#endif
#endif
#if defined(TEST_NTDLL)
@@ -62,6 +63,7 @@ const struct test winetest_testlist[] =
#if defined(_M_ARM)
{ "__rt_div", func___rt_div },
{ "__fto64", func___fto64 },
+ { "__64tof", func___64tof },
#endif
#endif
#if defined(TEST_STATIC_CRT)