Ticket #8914: time-failure.cpp

File time-failure.cpp, 408 bytes (added by jessicah, 5 years ago)
Line 
1#include <iostream>
2#include <ctime>
3#include <cstring>
4
5#undef NDEBUG
6#include <assert.h>
7
8using namespace std;
9
10int main()
11{
12 tm tm;
13 time_t t(0);
14 memset(&tm, 0, sizeof(tm));
15
16 cout << "zeroed tm" << endl;
17 assert(tm.tm_sec == 0);
18
19 cout << "gmtime_r" << endl;
20 assert(gmtime_r(&t, &tm));
21 assert(tm.tm_sec == 0);
22
23 cout << "mktime" << endl;
24 (void)mktime(&tm);
25 assert(tm.tm_sec == 0);
26
27 return 0;
28}