msvcp120/tests: Test _Xtime_diff_to_millis2 overflow behavior.

Signed-off-by: Stefan Dösinger <stefan@codeweavers.com>
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Stefan Dösinger 2017-10-17 17:41:56 +02:00 committed by Alexandre Julliard
parent 1d35db9f57
commit 9787af34b1
1 changed files with 21 additions and 1 deletions

View File

@ -576,6 +576,15 @@ static void test__Xtime_diff_to_millis2(void)
{0, 0, 0, 1234000001, 1235},
{0, 0, 0, 1234000009, 1235},
{0, 0, -1, 0, 0},
{1, 0, 0, 0, 0},
{0, 1000000000, 0, 0, 0},
{0x7FFFFFFF / 1000, 0, 0, 0, 0},
{2147484, 0, 0, 0, 0}, /* ceil(0x80000000 / 1000) */
{2147485, 0, 0, 0, 0}, /* ceil(0x80000000 / 1000) + 1*/
{0, 0, 0x7FFFFFFF / 1000, 0, 2147483000},
{0, 0, 0x7FFFFFFF / 1000, 647000000, 0x7FFFFFFF}, /* max */
{0, 0, 0x7FFFFFFF / 1000, 647000001, -2147483648}, /* overflow. */
{0, 0, 2147484, 0, -2147483296}, /* ceil(0x80000000 / 1000), overflow*/
{0, 0, 0, -10000000, 0},
{0, 0, -1, -100000000, 0},
{-1, 0, 0, 0, 1000},
@ -583,7 +592,18 @@ static void test__Xtime_diff_to_millis2(void)
{-1, -100000000, 0, 0, 1100},
{0, 0, -1, 2000000000, 1000},
{0, 0, -2, 2000000000, 0},
{0, 0, -2, 2100000000, 100}
{0, 0, -2, 2100000000, 100},
{0, 0, _I64_MAX / 1000, 0, -808}, /* Still fits in a signed 64 bit number */
{0, 0, _I64_MAX / 1000, 1000000000, 192}, /* Overflows a signed 64 bit number */
{0, 0, (((ULONGLONG)0x80000000 << 32) | 0x1000) / 1000, 1000000000, 4192}, /* 64 bit overflow */
{_I64_MAX - 2, 0, _I64_MAX, 0, 2000}, /* Not an overflow */
{_I64_MAX, 0, _I64_MAX - 2, 0, 0}, /* Not an overflow */
/* October 11th 2017, 12:34:59 UTC */
{1507725144, 983274000, 0, 0, 0},
{0, 0, 1507725144, 983274000, 191624088},
{1507725144, 983274000, 1507725145, 983274000, 1000},
{1507725145, 983274000, 1507725145, 983274000, 0},
};
int i;
MSVCRT_long ret;