Test case for Kernel File function
Uwe Bonnes
bon at elektron.ikp.physik.tu-darmstadt.de
Sat Mar 20 13:54:36 CST 2004
Changelog:
wine/dlls/kernel/tests/time.c
New File, runs OKAY on wine and NT4
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: wine/dlls/kernel/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/Makefile.in,v
retrieving revision 1.14
diff -u -r1.14 Makefile.in
--- wine/dlls/kernel/tests/Makefile.in 9 Feb 2004 20:58:16 -0000 1.14
+++ wine/dlls/kernel/tests/Makefile.in 20 Mar 2004 19:36:35 -0000
@@ -26,6 +26,7 @@
process.c \
profile.c \
thread.c \
+ time.c \
virtual.c
@MAKE_TEST_RULES@
--- /dev/null 2003-09-23 19:59:22.000000000 +0200
+++ wine/dlls/kernel/tests/time.c 2004-03-20 19:54:18.000000000 +0100
@@ -0,0 +1,103 @@
+#include "wine/test.h"
+#include "winbase.h"
+
+#define SECSPERMIN 60
+#define SECSPERDAY 86400
+/* 1601 to 1970 is 369 years plus 89 leap days */
+#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
+#define TICKSPERSEC 10000000
+#define TICKSPERMSEC 10000
+#define TICKS_1601_TO_1970 (SECS_1601_TO_1970 * TICKSPERSEC)
+
+
+void test_GetTimeZoneInformation()
+{
+ TIME_ZONE_INFORMATION tzinfo, tzinfo1;
+ DWORD res = GetTimeZoneInformation(&tzinfo);
+ ok(res != 0, "GetTimeZoneInformation failed\n");
+ ok(SetEnvironmentVariableA("TZ","GMT0") != 0,
+ "SetEnvironmentVariableA failed\n");
+ res = GetTimeZoneInformation(&tzinfo1);
+ ok(res != 0, "GetTimeZoneInformation failed\n");
+
+ ok(((tzinfo.Bias == tzinfo1.Bias) &&
+ (tzinfo.StandardBias == tzinfo1.StandardBias) &&
+ (tzinfo.DaylightBias == tzinfo1.DaylightBias)),
+ "Bias influenced by TZ variable\n");
+ ok(SetEnvironmentVariableA("TZ",NULL) != 0,
+ "SetEnvironmentVariableA failed\n");
+
+}
+
+void test_FileTimeToSystemTime()
+{
+ FILETIME ft;
+ SYSTEMTIME st;
+ ft.dwHighDateTime = 0;
+ ft.dwLowDateTime = 0;
+ ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970;
+
+ ok(FileTimeToSystemTime(&ft, &st),
+ "FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
+ ok(((st.wYear == 1601) && (st.wMonth == 1) && (st.wDay == 1) &&
+ (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 0) &&
+ (st.wMilliseconds == 0)),
+ "Got Year %4d Month %2d Day %2d\n", st.wYear, st.wMonth, st.wDay);
+
+ ft.dwHighDateTime = (UINT)(time >> 32);
+ ft.dwLowDateTime = (UINT)time;
+ ok(FileTimeToSystemTime(&ft, &st),
+ "FileTimeToSystemTime() failed with Error 0x%08lx\n",GetLastError());
+ ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
+ (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
+ (st.wMilliseconds == 0)),
+ "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
+ st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
+ st.wMilliseconds);
+}
+
+void test_FileTimeToLocalFileTime()
+{
+ FILETIME ft, lft;
+ SYSTEMTIME st;
+ TIME_ZONE_INFORMATION tzinfo;
+ DWORD res = GetTimeZoneInformation(&tzinfo);
+ ULONGLONG time = (ULONGLONG)TICKSPERSEC + TICKS_1601_TO_1970
+ + (ULONGLONG)tzinfo.Bias*SECSPERMIN *TICKSPERSEC;
+
+ ok( res != 0, "GetTimeZoneInformation failed\n");
+ ft.dwHighDateTime = (UINT)(time >> 32);
+ ft.dwLowDateTime = (UINT)time;
+ ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
+ "FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
+ FileTimeToSystemTime(&lft, &st);
+ ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
+ (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
+ (st.wMilliseconds == 0)),
+ "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
+ st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
+ st.wMilliseconds);
+
+ ok(SetEnvironmentVariableA("TZ","GMT") != 0,
+ "SetEnvironmentVariableA failed\n");
+ ok(res != 0, "GetTimeZoneInformation failed\n");
+ ok(FileTimeToLocalFileTime(&ft, &lft) !=0 ,
+ "FileTimeToLocalFileTime() failed with Error 0x%08lx\n",GetLastError());
+ FileTimeToSystemTime(&lft, &st);
+ ok(((st.wYear == 1970) && (st.wMonth == 1) && (st.wDay == 1) &&
+ (st.wHour == 0) && (st.wMinute == 0) && (st.wSecond == 1) &&
+ (st.wMilliseconds == 0)),
+ "Got Year %4d Month %2d Day %2d Hour %2d Min %2d Sec %2d mSec %3d\n",
+ st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond,
+ st.wMilliseconds);
+ ok(SetEnvironmentVariableA("TZ",NULL) != 0,
+ "SetEnvironmentVariableA failed\n");
+}
+
+START_TEST(time)
+{
+ test_GetTimeZoneInformation();
+ test_FileTimeToSystemTime();
+ test_FileTimeToLocalFileTime();
+
+}
More information about the wine-patches
mailing list