[PATCH] msvcp120/tests: Test _Xtime_diff_to_millis2 overflow behavior (v2).
Stefan Dösinger
stefan at codeweavers.com
Tue Oct 17 10:41:56 CDT 2017
Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
---
This applies on top of patch 137849.
Version 2: Fix constants > 0x7FFFFFFF.
---
dlls/msvcp120/tests/msvcp120.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 62165e9c49..c0d6f186b9 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -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;
--
2.13.6
More information about the wine-patches
mailing list