=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: msvcp120/tests: Test _Xtime_diff_to_millis2 overflow behavior.

Alexandre Julliard julliard at winehq.org
Tue Oct 17 15:12:10 CDT 2017


Module: wine
Branch: master
Commit: 9787af34b1c23deb67902fc7dbf2c8421b987048
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9787af34b1c23deb67902fc7dbf2c8421b987048

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Tue Oct 17 17:41:56 2017 +0200

msvcp120/tests: Test _Xtime_diff_to_millis2 overflow behavior.

Signed-off-by: Stefan Dösinger <stefan at codeweavers.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 62165e9..c0d6f18 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;




More information about the wine-cvs mailing list