Boundary test cases for SystemTimeToFileTime and GetDateFormat

Bill Medland billmedland at shaw.ca
Thu May 3 18:11:08 CDT 2007


Bill Medland (billmedland at shaw.ca)
Lower boundary test cases for SystemTimeToFileTime and GetDateFormat

Index: wine/dlls/kernel32/tests/locale.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel32/tests/locale.c,v
retrieving revision 1.11
diff -u -r1.11 locale.c
--- wine/dlls/kernel32/tests/locale.c	2 Apr 2007 11:24:36 -0000	1.11
+++ wine/dlls/kernel32/tests/locale.c	3 May 2007 22:21:55 -0000
@@ -424,6 +424,34 @@
   STRINGSW("dddd d MMMM yyyy","Wednesday 23 October 2002"); /* Incorrect DOW and time */
   ret = GetDateFormatW (lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
   EXPECT_VALID; EXPECT_LENW; EXPECT_EQW;
+
+  /* Limit tests */
+
+  curtime.wYear = 1601;
+  curtime.wMonth = 1;
+  curtime.wDay = 1;
+  curtime.wDayOfWeek = 0; /* Irrelevant */
+  curtime.wHour = 0;
+  curtime.wMinute = 0;
+  curtime.wSecond = 0;
+  curtime.wMilliseconds = 0;
+  STRINGSW("dddd d MMMM yyyy","Monday 1 January 1601");
+  SetLastError(0xdeadbeef);
+  ret = GetDateFormatW (lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
+  EXPECT_VALID; EXPECT_LENW; EXPECT_EQW;
+
+  curtime.wYear = 1600;
+  curtime.wMonth = 12;
+  curtime.wDay = 31;
+  curtime.wDayOfWeek = 0; /* Irrelevant */
+  curtime.wHour = 23;
+  curtime.wMinute = 59;
+  curtime.wSecond = 59;
+  curtime.wMilliseconds = 999;
+  STRINGSW("dddd d MMMM yyyy","Friday 31 December 1600");
+  SetLastError(0xdeadbeef);
+  ret = GetDateFormatW (lcid, 0, &curtime, input, buffer, COUNTOF(buffer));
+  EXPECT_INVALID;
 }
 
 
Index: wine/dlls/kernel32/tests/time.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel32/tests/time.c,v
retrieving revision 1.3
diff -u -r1.3 time.c
--- wine/dlls/kernel32/tests/time.c	4 Jan 2007 10:46:26 -0000	1.3
+++ wine/dlls/kernel32/tests/time.c	3 May 2007 22:22:04 -0000
@@ -73,6 +73,23 @@
     (st).wSecond = 32; \
     (st).wMilliseconds = 123;
 
+#define SETUP_ZEROTIME(st) \
+    (st).wYear = 1601; \
+    (st).wMonth = 1; \
+    (st).wDay = 1; \
+    (st).wHour = 0; \
+    (st).wMinute = 0; \
+    (st).wSecond = 0; \
+    (st).wMilliseconds = 0;
+
+#define SETUP_EARLY(st) \
+    (st).wYear = 1600; \
+    (st).wMonth = 12; \
+    (st).wDay = 31; \
+    (st).wHour = 23; \
+    (st).wMinute = 59; \
+    (st).wSecond = 59; \
+    (st).wMilliseconds = 999;
 
 
 static void test_conversions(void)
@@ -82,6 +99,17 @@
 
     memset(&ft,0,sizeof ft);
 
+    SETUP_EARLY(st)
+    ok (!SystemTimeToFileTime(&st, &ft), "Conversion succeeded EARLY\n");
+    ok (GetLastError() == ERROR_INVALID_PARAMETER, "EARLY should be INVALID\n");
+
+    SETUP_ZEROTIME(st)
+    ok (SystemTimeToFileTime(&st, &ft), "Conversion failed ZERO_TIME\n");
+    ok( (!((ft.dwHighDateTime != 0) || (ft.dwLowDateTime != 0))),
+        "Wrong time for ATIME: %08x %08x (correct %08x %08x)\n",
+        ft.dwLowDateTime, ft.dwHighDateTime, 0, 0);
+
+
     SETUP_ATIME(st)
     ok (SystemTimeToFileTime(&st,&ft), "Conversion Failed ATIME\n");
     ok( (!((ft.dwHighDateTime != ATIME_HI) || (ft.dwLowDateTime!=ATIME_LOW))),





More information about the wine-patches mailing list