mirror of
https://github.com/reactos/reactos.git
synced 2024-09-28 21:44:31 +00:00
[CRT_APITEST] Add tests for __i64tod/u64tod/i64tos/u64tos on ARM (#3866)
CORE-17713 CORE-17706 CORE-17604
This commit is contained in:
parent
9c4e3234ba
commit
a2e9dcf0a7
130
modules/rostests/apitests/crt/__64tof.c
Normal file
130
modules/rostests/apitests/crt/__64tof.c
Normal file
|
@ -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@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);
|
||||
}
|
||||
}
|
|
@ -1376,6 +1376,7 @@ elseif(ARCH STREQUAL "arm")
|
|||
list(APPEND SOURCE_MSVCRT
|
||||
__rt_div.c
|
||||
__fto64.c
|
||||
__64tof.c
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ elseif(ARCH STREQUAL "arm")
|
|||
list(APPEND SOURCE_STATIC
|
||||
__rt_div.c
|
||||
__fto64.c
|
||||
__64tof.c
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue