mirror of
https://github.com/reactos/reactos.git
synced 2025-04-04 12:39:35 +00:00
[CRT_APITEST] Add tests for __rt_sdiv/udiv/sdiv64/udiv64 on ARM
Addendum tof2bc1f0e
andf1e2c6cb
. CORE-17607 CORE-17614 CORE-17604
This commit is contained in:
parent
e996662afb
commit
759bdedc1e
3 changed files with 182 additions and 0 deletions
175
modules/rostests/apitests/crt/__rt_div.c
Normal file
175
modules/rostests/apitests/crt/__rt_div.c
Normal file
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: Tests for statically linked __rt_sdiv/udiv/sdiv64/udiv64 on ARM
|
||||
* COPYRIGHT: Copyright 2021 Stanislav Motylkov <x86corez@gmail.com>
|
||||
*/
|
||||
|
||||
#include <apitest.h>
|
||||
|
||||
typedef struct _SDIV_TEST_DATA
|
||||
{
|
||||
LONG dividend;
|
||||
LONG divisor;
|
||||
LONG expected_div;
|
||||
LONG expected_mod;
|
||||
} SDIV_TEST_DATA;
|
||||
|
||||
typedef struct _UDIV_TEST_DATA
|
||||
{
|
||||
ULONG dividend;
|
||||
ULONG divisor;
|
||||
ULONG expected_div;
|
||||
ULONG expected_mod;
|
||||
} UDIV_TEST_DATA;
|
||||
|
||||
typedef struct _SDIV64_TEST_DATA
|
||||
{
|
||||
LONGLONG dividend;
|
||||
LONGLONG divisor;
|
||||
LONGLONG expected_div;
|
||||
LONGLONG expected_mod;
|
||||
} SDIV64_TEST_DATA;
|
||||
|
||||
typedef struct _UDIV64_TEST_DATA
|
||||
{
|
||||
ULONGLONG dividend;
|
||||
ULONGLONG divisor;
|
||||
ULONGLONG expected_div;
|
||||
ULONGLONG expected_mod;
|
||||
} UDIV64_TEST_DATA;
|
||||
|
||||
START_TEST(__rt_div)
|
||||
{
|
||||
SDIV_TEST_DATA sdiv[] =
|
||||
{
|
||||
/* Dividend is larger than divisor */
|
||||
{ 3425, 400, 8, 225 },
|
||||
{ -3425, 400, -8, -225 },
|
||||
{ 3425, -400, -8, 225 },
|
||||
{ -3425, -400, 8, -225 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 12, 42, 0, 12 },
|
||||
{ -12, 42, 0, -12 },
|
||||
{ 12, -42, 0, 12 },
|
||||
{ -12, -42, 0, -12 },
|
||||
/* Division without remainder */
|
||||
{ 16777216, 65536, 256, 0 },
|
||||
{ -16777216, 65536, -256, 0 },
|
||||
{ 16777216, -65536, -256, 0 },
|
||||
{ -16777216, -65536, 256, 0 },
|
||||
};
|
||||
UDIV_TEST_DATA udiv[] =
|
||||
{
|
||||
/* Dividend is larger than divisor */
|
||||
{ 3425, 400, 8, 225 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 12, 42, 0, 12 },
|
||||
/* Division without remainder */
|
||||
{ 16777216, 65536, 256, 0 },
|
||||
};
|
||||
SDIV64_TEST_DATA sdiv64[] =
|
||||
{
|
||||
/* Dividend is larger than divisor */
|
||||
{ 34918215, 7, 4988316, 3 },
|
||||
{ -34918215, 7, -4988316, -3 },
|
||||
{ 34918215, -7, -4988316, 3 },
|
||||
{ -34918215, -7, 4988316, -3 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 12, 42, 0, 12 },
|
||||
{ -12, 42, 0, -12 },
|
||||
{ 12, -42, 0, 12 },
|
||||
{ -12, -42, 0, -12 },
|
||||
/* Division without remainder */
|
||||
{ 16777216, 65536, 256, 0 },
|
||||
{ -16777216, 65536, -256, 0 },
|
||||
{ 16777216, -65536, -256, 0 },
|
||||
{ -16777216, -65536, 256, 0 },
|
||||
|
||||
/* Big 64-bit numbers */
|
||||
|
||||
/* Dividend is larger than divisor */
|
||||
{ 0x2AFFFFFFFLL * 100, 400, 2885681151LL, 300 },
|
||||
{ -0x2AFFFFFFFLL * 100, 400, -2885681151LL, -300 },
|
||||
{ 0x2AFFFFFFFLL * 100, -400, -2885681151LL, 300 },
|
||||
{ -0x2AFFFFFFFLL * 100, -400, 2885681151LL, -300 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 },
|
||||
{ -0x2AFFFFFFFLL * 50, 0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 },
|
||||
{ 0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, 0x2AFFFFFFFLL * 50 },
|
||||
{ -0x2AFFFFFFFLL * 50, -0x2AFFFFFFFLL * 100, 0, -0x2AFFFFFFFLL * 50 },
|
||||
/* Division without remainder */
|
||||
{ 0x2AFFFFFFFLL * 100, 100, 0x2AFFFFFFFLL, 0 },
|
||||
{ -0x2AFFFFFFFLL * 100, 100, -0x2AFFFFFFFLL, 0 },
|
||||
{ 0x2AFFFFFFFLL * 100, -100, -0x2AFFFFFFFLL, 0 },
|
||||
{ -0x2AFFFFFFFLL * 100, -100, 0x2AFFFFFFFLL, 0 },
|
||||
};
|
||||
UDIV64_TEST_DATA udiv64[] =
|
||||
{
|
||||
/* Dividend is larger than divisor */
|
||||
{ 34918215, 7, 4988316, 3 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 12, 42, 0, 12 },
|
||||
/* Division without remainder */
|
||||
{ 16777216, 65536, 256, 0 },
|
||||
|
||||
/* Big 64-bit numbers */
|
||||
|
||||
/* Dividend is larger than divisor */
|
||||
{ 0x2AFFFFFFFULL * 100, 400, 2885681151ULL, 300 },
|
||||
/* Divisor is larger than dividend */
|
||||
{ 0x2AFFFFFFFULL * 50, 0x2AFFFFFFFULL * 100, 0, 0x2AFFFFFFFULL * 50 },
|
||||
/* Division without remainder */
|
||||
{ 0x2AFFFFFFFULL * 100, 100, 0x2AFFFFFFFULL, 0 },
|
||||
};
|
||||
INT i;
|
||||
|
||||
for (i = 0; i < _countof(sdiv); i++)
|
||||
{
|
||||
LONG test_div, test_mod;
|
||||
|
||||
test_div = sdiv[i].dividend / sdiv[i].divisor;
|
||||
test_mod = sdiv[i].dividend % sdiv[i].divisor;
|
||||
ok(test_div == sdiv[i].expected_div, "(sdiv) %d: Expected %ld, got %ld / %ld = %ld\n",
|
||||
i, sdiv[i].expected_div, sdiv[i].dividend, sdiv[i].divisor, test_div);
|
||||
ok(test_mod == sdiv[i].expected_mod, "(sdiv) %d: Expected %ld, got %ld %% %ld = %ld\n",
|
||||
i, sdiv[i].expected_mod, sdiv[i].dividend, sdiv[i].divisor, test_mod);
|
||||
}
|
||||
|
||||
for (i = 0; i < _countof(udiv); i++)
|
||||
{
|
||||
ULONG test_div, test_mod;
|
||||
|
||||
test_div = udiv[i].dividend / udiv[i].divisor;
|
||||
test_mod = udiv[i].dividend % udiv[i].divisor;
|
||||
ok(test_div == udiv[i].expected_div, "(udiv) %d: Expected %lu, got %lu / %lu = %lu\n",
|
||||
i, udiv[i].expected_div, udiv[i].dividend, udiv[i].divisor, test_div);
|
||||
ok(test_mod == udiv[i].expected_mod, "(udiv) %d: Expected %lu, got %lu %% %lu = %lu\n",
|
||||
i, udiv[i].expected_mod, udiv[i].dividend, udiv[i].divisor, test_mod);
|
||||
}
|
||||
|
||||
for (i = 0; i < _countof(sdiv64); i++)
|
||||
{
|
||||
LONGLONG test_div, test_mod;
|
||||
|
||||
test_div = sdiv64[i].dividend / sdiv64[i].divisor;
|
||||
test_mod = sdiv64[i].dividend % sdiv64[i].divisor;
|
||||
ok(test_div == sdiv64[i].expected_div, "(sdiv64) %d: Expected %lld, got %lld / %lld = %lld\n",
|
||||
i, sdiv64[i].expected_div, sdiv64[i].dividend, sdiv64[i].divisor, test_div);
|
||||
ok(test_mod == sdiv64[i].expected_mod, "(sdiv64) %d: Expected %lld, got %lld %% %lld = %lld\n",
|
||||
i, sdiv64[i].expected_mod, sdiv64[i].dividend, sdiv64[i].divisor, test_mod);
|
||||
}
|
||||
|
||||
for (i = 0; i < _countof(udiv64); i++)
|
||||
{
|
||||
ULONGLONG test_div, test_mod;
|
||||
|
||||
test_div = udiv64[i].dividend / udiv64[i].divisor;
|
||||
test_mod = udiv64[i].dividend % udiv64[i].divisor;
|
||||
ok(test_div == udiv64[i].expected_div, "(udiv64) %d: Expected %llu, got %llu / %llu = %llu\n",
|
||||
i, udiv64[i].expected_div, udiv64[i].dividend, udiv64[i].divisor, test_div);
|
||||
ok(test_mod == udiv64[i].expected_mod, "(udiv64) %d: Expected %llu, got %llu %% %llu = %llu\n",
|
||||
i, udiv64[i].expected_mod, udiv64[i].dividend, udiv64[i].divisor, test_mod);
|
||||
}
|
||||
}
|
||||
|
|
@ -1371,6 +1371,10 @@ elseif(ARCH STREQUAL "amd64")
|
|||
# sinf.c
|
||||
# sqrtf.c
|
||||
)
|
||||
elseif(ARCH STREQUAL "arm")
|
||||
list(APPEND SOURCE_MSVCRT
|
||||
__rt_div.c
|
||||
)
|
||||
endif()
|
||||
|
||||
# Startup code doesn't go together well with the static CRT... too much __imp_
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <apitest.h>
|
||||
|
||||
#if defined(TEST_MSVCRT)
|
||||
extern void func___rt_div(void);
|
||||
extern void func__vscprintf(void);
|
||||
extern void func__vscwprintf(void);
|
||||
extern void func_atexit(void);
|
||||
|
@ -59,6 +60,8 @@ const struct test winetest_testlist[] =
|
|||
{ "atexit", func_atexit },
|
||||
#if defined(_M_IX86)
|
||||
{ "__getmainargs", func___getmainargs },
|
||||
#elif defined(_M_ARM)
|
||||
{ "__rt_div", func___rt_div },
|
||||
#endif
|
||||
{ "_vscprintf", func__vscprintf },
|
||||
{ "_vscwprintf", func__vscwprintf },
|
||||
|
|
Loading…
Reference in a new issue