2 * Unit test suite for time functions.
4 * Copyright 2004 Uwe Bonnes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
26 #include <stdlib.h> /*setenv*/
27 #include <stdio.h> /*printf*/
30 #define _MAX__TIME64_T (((__time64_t)0x00000007 << 32) | 0x93406FFF)
32 #define SECSPERDAY 86400
33 #define SECSPERHOUR 3600
35 #define MINSPERHOUR 60
36 #define HOURSPERDAY 24
38 static __time32_t (__cdecl
*p_mkgmtime32
)(struct tm
*);
39 static struct tm
* (__cdecl
*p_gmtime32
)(__time32_t
*);
40 static errno_t (__cdecl
*p_gmtime32_s
)(struct tm
*, __time32_t
*);
41 static errno_t (__cdecl
*p_strtime_s
)(char*,size_t);
42 static errno_t (__cdecl
*p_strdate_s
)(char*,size_t);
43 static errno_t (__cdecl
*p_localtime32_s
)(struct tm
*, __time32_t
*);
44 static errno_t (__cdecl
*p_localtime64_s
)(struct tm
*, __time64_t
*);
46 static void init(void)
48 HMODULE hmod
= GetModuleHandleA("msvcrt.dll");
50 p_gmtime32
= (void*)GetProcAddress(hmod
, "_gmtime32");
51 p_gmtime32_s
= (void*)GetProcAddress(hmod
, "_gmtime32_s");
52 p_mkgmtime32
= (void*)GetProcAddress(hmod
, "_mkgmtime32");
53 p_strtime_s
= (void*)GetProcAddress(hmod
, "_strtime_s");
54 p_strdate_s
= (void*)GetProcAddress(hmod
, "_strdate_s");
55 p_localtime32_s
= (void*)GetProcAddress(hmod
, "_localtime32_s");
56 p_localtime64_s
= (void*)GetProcAddress(hmod
, "_localtime64_s");
59 static int get_test_year(time_t *start
)
61 time_t now
= time(NULL
);
62 struct tm
*tm
= localtime(&now
);
64 /* compute start of year in seconds */
65 *start
= SECSPERDAY
* ((tm
->tm_year
- 70) * 365 +
66 (tm
->tm_year
- 69) / 4 -
67 (tm
->tm_year
- 1) / 100 +
68 (tm
->tm_year
+ 299) / 400);
72 static void test_ctime(void)
76 ret
= ctime(&badtime
);
77 ok(ret
== NULL
, "expected ctime to return NULL, got %s\n", ret
);
79 static void test_gmtime(void)
81 __time32_t valid
, gmt
;
82 struct tm
* gmt_tm
, gmt_tm_s
;
86 win_skip("Skipping _gmtime32 tests\n");
90 gmt_tm
= p_gmtime32(NULL
);
91 ok(gmt_tm
== NULL
, "gmt_tm != NULL\n");
94 gmt_tm
= p_gmtime32(&gmt
);
95 ok(gmt_tm
== NULL
, "gmt_tm != NULL\n");
98 gmt_tm
= p_gmtime32(&gmt
);
100 ok(0, "_gmtime32() failed\n");
104 ok(((gmt_tm
->tm_year
== 70) && (gmt_tm
->tm_mon
== 0) && (gmt_tm
->tm_yday
== 0) &&
105 (gmt_tm
->tm_mday
== 1) && (gmt_tm
->tm_wday
== 4) && (gmt_tm
->tm_hour
== 0) &&
106 (gmt_tm
->tm_min
== 0) && (gmt_tm
->tm_sec
== 0) && (gmt_tm
->tm_isdst
== 0)),
107 "Wrong date:Year %4d mon %2d yday %3d mday %2d wday %1d hour%2d min %2d sec %2d dst %2d\n",
108 gmt_tm
->tm_year
, gmt_tm
->tm_mon
, gmt_tm
->tm_yday
, gmt_tm
->tm_mday
, gmt_tm
->tm_wday
,
109 gmt_tm
->tm_hour
, gmt_tm
->tm_min
, gmt_tm
->tm_sec
, gmt_tm
->tm_isdst
);
112 win_skip("Skipping _mkgmtime32 tests\n");
116 gmt_tm
->tm_wday
= gmt_tm
->tm_yday
= 0;
117 gmt
= p_mkgmtime32(gmt_tm
);
118 ok(gmt
== valid
, "gmt = %u\n", gmt
);
119 ok(gmt_tm
->tm_wday
== 4, "gmt_tm->tm_wday = %d\n", gmt_tm
->tm_wday
);
120 ok(gmt_tm
->tm_yday
== 0, "gmt_tm->tm_yday = %d\n", gmt_tm
->tm_yday
);
122 gmt_tm
->tm_wday
= gmt_tm
->tm_yday
= 0;
123 gmt_tm
->tm_isdst
= -1;
124 gmt
= p_mkgmtime32(gmt_tm
);
125 ok(gmt
== valid
, "gmt = %u\n", gmt
);
126 ok(gmt_tm
->tm_wday
== 4, "gmt_tm->tm_wday = %d\n", gmt_tm
->tm_wday
);
127 ok(gmt_tm
->tm_yday
== 0, "gmt_tm->tm_yday = %d\n", gmt_tm
->tm_yday
);
129 gmt_tm
->tm_wday
= gmt_tm
->tm_yday
= 0;
130 gmt_tm
->tm_isdst
= 1;
131 gmt
= p_mkgmtime32(gmt_tm
);
132 ok(gmt
== valid
, "gmt = %u\n", gmt
);
133 ok(gmt_tm
->tm_wday
== 4, "gmt_tm->tm_wday = %d\n", gmt_tm
->tm_wday
);
134 ok(gmt_tm
->tm_yday
== 0, "gmt_tm->tm_yday = %d\n", gmt_tm
->tm_yday
);
136 gmt
= valid
= 173921;
137 gmt_tm
= p_gmtime32(&gmt
);
139 ok(0, "_gmtime32() failed\n");
143 gmt_tm
->tm_isdst
= -1;
144 gmt
= p_mkgmtime32(gmt_tm
);
145 ok(gmt
== valid
, "gmt = %u\n", gmt
);
146 ok(gmt_tm
->tm_wday
== 6, "gmt_tm->tm_wday = %d\n", gmt_tm
->tm_wday
);
147 ok(gmt_tm
->tm_yday
== 2, "gmt_tm->tm_yday = %d\n", gmt_tm
->tm_yday
);
149 gmt_tm
->tm_isdst
= 1;
150 gmt
= p_mkgmtime32(gmt_tm
);
151 ok(gmt
== valid
, "gmt = %u\n", gmt
);
154 win_skip("Skipping _gmtime32_s tests\n");
160 err
= p_gmtime32_s(NULL
, &gmt
);
161 ok(err
== EINVAL
, "err = %d\n", err
);
162 ok(errno
== EINVAL
, "errno = %d\n", errno
);
166 err
= p_gmtime32_s(&gmt_tm_s
, &gmt
);
167 ok(err
== EINVAL
, "err = %d\n", err
);
168 ok(errno
== EINVAL
, "errno = %d\n", errno
);
169 ok(gmt_tm_s
.tm_year
== -1, "tm_year = %d\n", gmt_tm_s
.tm_year
);
172 static void test_mktime(void)
174 TIME_ZONE_INFORMATION tzinfo
;
175 DWORD res
= GetTimeZoneInformation(&tzinfo
);
176 struct tm my_tm
, sav_tm
;
177 time_t nulltime
, local_time
;
183 year
= get_test_year( &ref
);
186 ok (res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
187 WideCharToMultiByte( CP_ACP
, 0, tzinfo
.StandardName
, -1, buffer
, sizeof(buffer
), NULL
, NULL
);
188 trace( "bias %d std %d dst %d zone %s\n",
189 tzinfo
.Bias
, tzinfo
.StandardBias
, tzinfo
.DaylightBias
, buffer
);
190 /* Bias may be positive or negative, to use offset of one day */
191 my_tm
= *localtime(&ref
); /* retrieve current dst flag */
192 secs
= SECSPERDAY
- tzinfo
.Bias
* SECSPERMIN
;
193 secs
-= (my_tm
.tm_isdst
? tzinfo
.DaylightBias
: tzinfo
.StandardBias
) * SECSPERMIN
;
194 my_tm
.tm_mday
= 1 + secs
/SECSPERDAY
;
195 secs
= secs
% SECSPERDAY
;
196 my_tm
.tm_hour
= secs
/ SECSPERHOUR
;
197 secs
= secs
% SECSPERHOUR
;
198 my_tm
.tm_min
= secs
/ SECSPERMIN
;
199 secs
= secs
% SECSPERMIN
;
202 my_tm
.tm_year
= year
;
207 local_time
= mktime(&my_tm
);
208 ok(local_time
== ref
, "mktime returned %u, expected %u\n",
209 (DWORD
)local_time
, (DWORD
)ref
);
210 /* now test some unnormalized struct tm's */
214 local_time
= mktime(&my_tm
);
215 ok(local_time
== ref
, "Unnormalized mktime returned %u, expected %u\n",
216 (DWORD
)local_time
, (DWORD
)ref
);
217 ok( my_tm
.tm_year
== sav_tm
.tm_year
&& my_tm
.tm_mon
== sav_tm
.tm_mon
&&
218 my_tm
.tm_mday
== sav_tm
.tm_mday
&& my_tm
.tm_hour
== sav_tm
.tm_hour
&&
219 my_tm
.tm_sec
== sav_tm
.tm_sec
,
220 "mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
221 my_tm
.tm_year
,my_tm
.tm_mon
,my_tm
.tm_mday
,
222 my_tm
.tm_hour
,my_tm
.tm_sec
,
223 sav_tm
.tm_year
,sav_tm
.tm_mon
,sav_tm
.tm_mday
,
224 sav_tm
.tm_hour
,sav_tm
.tm_sec
);
228 local_time
= mktime(&my_tm
);
229 ok(local_time
== ref
, "Unnormalized mktime returned %u, expected %u\n",
230 (DWORD
)local_time
, (DWORD
)ref
);
231 ok( my_tm
.tm_year
== sav_tm
.tm_year
&& my_tm
.tm_mon
== sav_tm
.tm_mon
&&
232 my_tm
.tm_mday
== sav_tm
.tm_mday
&& my_tm
.tm_hour
== sav_tm
.tm_hour
&&
233 my_tm
.tm_sec
== sav_tm
.tm_sec
,
234 "mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
235 my_tm
.tm_year
,my_tm
.tm_mon
,my_tm
.tm_mday
,
236 my_tm
.tm_hour
,my_tm
.tm_sec
,
237 sav_tm
.tm_year
,sav_tm
.tm_mon
,sav_tm
.tm_mday
,
238 sav_tm
.tm_hour
,sav_tm
.tm_sec
);
242 local_time
= mktime(&my_tm
);
243 ok(local_time
== ref
, "Unnormalized mktime returned %u, expected %u\n",
244 (DWORD
)local_time
, (DWORD
)ref
);
245 ok( my_tm
.tm_year
== sav_tm
.tm_year
&& my_tm
.tm_mon
== sav_tm
.tm_mon
&&
246 my_tm
.tm_mday
== sav_tm
.tm_mday
&& my_tm
.tm_hour
== sav_tm
.tm_hour
&&
247 my_tm
.tm_sec
== sav_tm
.tm_sec
,
248 "mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
249 my_tm
.tm_year
,my_tm
.tm_mon
,my_tm
.tm_mday
,
250 my_tm
.tm_hour
,my_tm
.tm_sec
,
251 sav_tm
.tm_year
,sav_tm
.tm_mon
,sav_tm
.tm_mday
,
252 sav_tm
.tm_hour
,sav_tm
.tm_sec
);
256 local_time
= mktime(&my_tm
);
257 ok(local_time
== ref
, "Unnormalized mktime returned %u, expected %u\n",
258 (DWORD
)local_time
, (DWORD
)ref
);
259 ok( my_tm
.tm_year
== sav_tm
.tm_year
&& my_tm
.tm_mon
== sav_tm
.tm_mon
&&
260 my_tm
.tm_mday
== sav_tm
.tm_mday
&& my_tm
.tm_hour
== sav_tm
.tm_hour
&&
261 my_tm
.tm_sec
== sav_tm
.tm_sec
,
262 "mktime returned %2d-%02d-%02d %02d:%02d expected %2d-%02d-%02d %02d:%02d\n",
263 my_tm
.tm_year
,my_tm
.tm_mon
,my_tm
.tm_mday
,
264 my_tm
.tm_hour
,my_tm
.tm_sec
,
265 sav_tm
.tm_year
,sav_tm
.tm_mon
,sav_tm
.tm_mday
,
266 sav_tm
.tm_hour
,sav_tm
.tm_sec
);
267 /* now a bad time example */
270 local_time
= mktime(&my_tm
);
271 ok((local_time
== -1), "(bad time) mktime returned %d, expected -1\n", (int)local_time
);
274 /* TEST that we are independent from the TZ variable */
275 /*Argh, msvcrt doesn't have setenv() */
276 _snprintf(TZ_env
,255,"TZ=%s",(getenv("TZ")?getenv("TZ"):""));
278 nulltime
= mktime(&my_tm
);
279 ok(nulltime
== ref
,"mktime returned 0x%08x\n",(DWORD
)nulltime
);
283 static void test_localtime(void)
285 TIME_ZONE_INFORMATION tzinfo
;
286 DWORD res
= GetTimeZoneInformation(&tzinfo
);
291 int year
= get_test_year( &ref
);
292 int is_leap
= !(year
% 4) && ((year
% 100) || !((year
+ 300) % 400));
294 gmt
= ref
+ SECSPERDAY
+ tzinfo
.Bias
* SECSPERMIN
;
295 ok (res
!= TIME_ZONE_ID_INVALID
, "GetTimeZoneInformation failed\n");
296 lt
= localtime(&gmt
);
297 gmt
+= (lt
->tm_isdst
? tzinfo
.DaylightBias
: tzinfo
.StandardBias
) * SECSPERMIN
;
298 lt
= localtime(&gmt
);
299 ok(((lt
->tm_year
== year
) && (lt
->tm_mon
== 0) && (lt
->tm_yday
== 1) &&
300 (lt
->tm_mday
== 2) && (lt
->tm_hour
== 0) &&
301 (lt
->tm_min
== 0) && (lt
->tm_sec
== 0)),
302 "Wrong date:Year %d mon %d yday %d mday %d wday %d hour %d min %d sec %d dst %d\n",
303 lt
->tm_year
, lt
->tm_mon
, lt
->tm_yday
, lt
->tm_mday
, lt
->tm_wday
, lt
->tm_hour
,
304 lt
->tm_min
, lt
->tm_sec
, lt
->tm_isdst
);
306 _snprintf(TZ_env
,255,"TZ=%s",(getenv("TZ")?getenv("TZ"):""));
308 lt
= localtime(&gmt
);
309 ok(((lt
->tm_year
== year
) && (lt
->tm_mon
== 0) && (lt
->tm_yday
== 1) &&
310 (lt
->tm_mday
== 2) && (lt
->tm_hour
== 0) &&
311 (lt
->tm_min
== 0) && (lt
->tm_sec
== 0)),
312 "Wrong date:Year %d mon %d yday %d mday %d wday %d hour %d min %d sec %d dst %d\n",
313 lt
->tm_year
, lt
->tm_mon
, lt
->tm_yday
, lt
->tm_mday
, lt
->tm_wday
, lt
->tm_hour
,
314 lt
->tm_min
, lt
->tm_sec
, lt
->tm_isdst
);
318 gmt
= ref
+ 202 * SECSPERDAY
+ tzinfo
.Bias
* SECSPERMIN
;
319 lt
= localtime(&gmt
);
320 gmt
+= (lt
->tm_isdst
? tzinfo
.DaylightBias
: tzinfo
.StandardBias
) * SECSPERMIN
;
321 lt
= localtime(&gmt
);
322 ok(((lt
->tm_year
== year
) && (lt
->tm_mon
== 6) && (lt
->tm_yday
== 202) &&
323 (lt
->tm_mday
== 22 - is_leap
) && (lt
->tm_hour
== 0) &&
324 (lt
->tm_min
== 0) && (lt
->tm_sec
== 0)),
325 "Wrong date:Year %d mon %d yday %d mday %d wday %d hour %d min %d sec %d dst %d\n",
326 lt
->tm_year
, lt
->tm_mon
, lt
->tm_yday
, lt
->tm_mday
, lt
->tm_wday
, lt
->tm_hour
,
327 lt
->tm_min
, lt
->tm_sec
, lt
->tm_isdst
);
330 static void test_strdate(void)
332 char date
[16], * result
;
333 int month
, day
, year
, count
, len
;
336 result
= _strdate(date
);
337 ok(result
== date
, "Wrong return value\n");
339 ok(len
== 8, "Wrong length: returned %d, should be 8\n", len
);
340 count
= sscanf(date
, "%02d/%02d/%02d", &month
, &day
, &year
);
341 ok(count
== 3, "Wrong format: count = %d, should be 3\n", count
);
344 win_skip("Skipping _strdate_s tests\n");
349 err
= p_strdate_s(NULL
, 1);
350 ok(err
== EINVAL
, "err = %d\n", err
);
351 ok(errno
== EINVAL
, "errno = %d\n", errno
);
355 err
= p_strdate_s(date
, 8);
356 ok(err
== ERANGE
, "err = %d\n", err
);
357 ok(errno
== ERANGE
, "errno = %d\n", errno
);
358 ok(date
[0] == '\0', "date[0] != '\\0'\n");
359 ok(date
[1] == 'x', "date[1] != 'x'\n");
361 err
= p_strdate_s(date
, 9);
362 ok(err
== 0, "err = %x\n", err
);
365 static void test_strtime(void)
367 char time
[16], * result
;
368 int hour
, minute
, second
, count
, len
;
371 result
= _strtime(time
);
372 ok(result
== time
, "Wrong return value\n");
374 ok(len
== 8, "Wrong length: returned %d, should be 8\n", len
);
375 count
= sscanf(time
, "%02d:%02d:%02d", &hour
, &minute
, &second
);
376 ok(count
== 3, "Wrong format: count = %d, should be 3\n", count
);
379 win_skip("Skipping _strtime_s tests\n");
384 err
= p_strtime_s(NULL
, 0);
385 ok(err
== EINVAL
, "err = %d\n", err
);
386 ok(errno
== EINVAL
, "errno = %d\n", errno
);
388 err
= p_strtime_s(NULL
, 1);
389 ok(err
== EINVAL
, "err = %d\n", err
);
390 ok(errno
== EINVAL
, "errno = %d\n", errno
);
393 err
= p_strtime_s(time
, 8);
394 ok(err
== ERANGE
, "err = %d\n", err
);
395 ok(errno
== ERANGE
, "errno = %d\n", errno
);
396 ok(time
[0] == '\0', "time[0] != '\\0'\n");
398 err
= p_strtime_s(time
, 9);
399 ok(err
== 0, "err = %x\n", err
);
402 static void test_wstrdate(void)
404 wchar_t date
[16], * result
;
405 int month
, day
, year
, count
, len
;
406 wchar_t format
[] = { '%','0','2','d','/','%','0','2','d','/','%','0','2','d',0 };
408 result
= _wstrdate(date
);
409 ok(result
== date
, "Wrong return value\n");
411 ok(len
== 8, "Wrong length: returned %d, should be 8\n", len
);
412 count
= swscanf(date
, format
, &month
, &day
, &year
);
413 ok(count
== 3, "Wrong format: count = %d, should be 3\n", count
);
416 static void test_wstrtime(void)
418 wchar_t time
[16], * result
;
419 int hour
, minute
, second
, count
, len
;
420 wchar_t format
[] = { '%','0','2','d',':','%','0','2','d',':','%','0','2','d',0 };
422 result
= _wstrtime(time
);
423 ok(result
== time
, "Wrong return value\n");
425 ok(len
== 8, "Wrong length: returned %d, should be 8\n", len
);
426 count
= swscanf(time
, format
, &hour
, &minute
, &second
);
427 ok(count
== 3, "Wrong format: count = %d, should be 3\n", count
);
430 static void test_localtime32_s(void)
436 if (!p_localtime32_s
)
438 win_skip("Skipping _localtime32_s tests\n");
443 err
= p_localtime32_s(NULL
, NULL
);
444 ok(err
== EINVAL
, "Expected _localtime32_s to return EINVAL, got %d\n", err
);
445 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
449 err
= p_localtime32_s(NULL
, &time
);
450 ok(err
== EINVAL
, "Expected _localtime32_s to return EINVAL, got %d\n", err
);
451 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
453 memset(&tm
, 0, sizeof(tm
));
455 err
= p_localtime32_s(&tm
, NULL
);
456 ok(err
== EINVAL
, "Expected _localtime32_s to return EINVAL, got %d\n", err
);
457 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
458 ok(tm
.tm_sec
== -1 && tm
.tm_min
== -1 && tm
.tm_hour
== -1 &&
459 tm
.tm_mday
== -1 && tm
.tm_mon
== -1 && tm
.tm_year
== -1 &&
460 tm
.tm_wday
== -1 && tm
.tm_yday
== -1 && tm
.tm_isdst
== -1,
461 "Expected tm structure members to be initialized to -1, got "
462 "(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n", tm
.tm_sec
, tm
.tm_min
,
463 tm
.tm_hour
, tm
.tm_mday
, tm
.tm_mon
, tm
.tm_year
, tm
.tm_wday
, tm
.tm_yday
,
466 memset(&tm
, 0, sizeof(tm
));
469 err
= p_localtime32_s(&tm
, &time
);
470 ok(err
== EINVAL
, "Expected _localtime32_s to return EINVAL, got %d\n", err
);
471 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
472 ok(tm
.tm_sec
== -1 && tm
.tm_min
== -1 && tm
.tm_hour
== -1 &&
473 tm
.tm_mday
== -1 && tm
.tm_mon
== -1 && tm
.tm_year
== -1 &&
474 tm
.tm_wday
== -1 && tm
.tm_yday
== -1 && tm
.tm_isdst
== -1,
475 "Expected tm structure members to be initialized to -1, got "
476 "(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n", tm
.tm_sec
, tm
.tm_min
,
477 tm
.tm_hour
, tm
.tm_mday
, tm
.tm_mon
, tm
.tm_year
, tm
.tm_wday
, tm
.tm_yday
,
481 static void test_localtime64_s(void)
487 if (!p_localtime64_s
)
489 win_skip("Skipping _localtime64_s tests\n");
494 err
= p_localtime64_s(NULL
, NULL
);
495 ok(err
== EINVAL
, "Expected _localtime64_s to return EINVAL, got %d\n", err
);
496 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
500 err
= p_localtime64_s(NULL
, &time
);
501 ok(err
== EINVAL
, "Expected _localtime64_s to return EINVAL, got %d\n", err
);
502 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
504 memset(&tm
, 0, sizeof(tm
));
506 err
= p_localtime64_s(&tm
, NULL
);
507 ok(err
== EINVAL
, "Expected _localtime64_s to return EINVAL, got %d\n", err
);
508 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
509 ok(tm
.tm_sec
== -1 && tm
.tm_min
== -1 && tm
.tm_hour
== -1 &&
510 tm
.tm_mday
== -1 && tm
.tm_mon
== -1 && tm
.tm_year
== -1 &&
511 tm
.tm_wday
== -1 && tm
.tm_yday
== -1 && tm
.tm_isdst
== -1,
512 "Expected tm structure members to be initialized to -1, got "
513 "(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n", tm
.tm_sec
, tm
.tm_min
,
514 tm
.tm_hour
, tm
.tm_mday
, tm
.tm_mon
, tm
.tm_year
, tm
.tm_wday
, tm
.tm_yday
,
517 memset(&tm
, 0, sizeof(tm
));
520 err
= p_localtime64_s(&tm
, &time
);
521 ok(err
== EINVAL
, "Expected _localtime64_s to return EINVAL, got %d\n", err
);
522 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
523 ok(tm
.tm_sec
== -1 && tm
.tm_min
== -1 && tm
.tm_hour
== -1 &&
524 tm
.tm_mday
== -1 && tm
.tm_mon
== -1 && tm
.tm_year
== -1 &&
525 tm
.tm_wday
== -1 && tm
.tm_yday
== -1 && tm
.tm_isdst
== -1,
526 "Expected tm structure members to be initialized to -1, got "
527 "(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n", tm
.tm_sec
, tm
.tm_min
,
528 tm
.tm_hour
, tm
.tm_mday
, tm
.tm_mon
, tm
.tm_year
, tm
.tm_wday
, tm
.tm_yday
,
531 memset(&tm
, 0, sizeof(tm
));
532 time
= _MAX__TIME64_T
+ 1;
534 err
= p_localtime64_s(&tm
, &time
);
535 ok(err
== EINVAL
, "Expected _localtime64_s to return EINVAL, got %d\n", err
);
536 ok(errno
== EINVAL
, "Expected errno to be EINVAL, got %d\n", errno
);
537 ok(tm
.tm_sec
== -1 && tm
.tm_min
== -1 && tm
.tm_hour
== -1 &&
538 tm
.tm_mday
== -1 && tm
.tm_mon
== -1 && tm
.tm_year
== -1 &&
539 tm
.tm_wday
== -1 && tm
.tm_yday
== -1 && tm
.tm_isdst
== -1,
540 "Expected tm structure members to be initialized to -1, got "
541 "(%d, %d, %d, %d, %d, %d, %d, %d, %d)\n", tm
.tm_sec
, tm
.tm_min
,
542 tm
.tm_hour
, tm
.tm_mday
, tm
.tm_mon
, tm
.tm_year
, tm
.tm_wday
, tm
.tm_yday
,
558 test_localtime32_s();
559 test_localtime64_s();