test-utc-mktime.c revision ac3de45a2b7f7411f18bf3c0f0bc8dd54519944a
/* Copyright (c) 2007-2017 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "utc-mktime.h"
struct test_utc_mktime_input {
};
void test_utc_mktime(void)
{
static const struct test_utc_mktime_input input[] = {
#ifdef TIME_T_SIGNED
{ 1969, 12, 31, 23, 59, 59 },
{ 1901, 12, 13, 20, 45, 53 },
#endif
{ 2106, 2, 7, 6, 28, 15 },
#endif
{ 2007, 11, 7, 1, 7, 20 },
{ 1970, 1, 1, 0, 0, 0 },
{ 2038, 1, 19, 3, 14, 7 },
{ 2038, 1, 19, 3, 14, 8 },
{ 2106, 2, 7, 6, 28, 15 },
{ 2106, 2, 7, 6, 28, 16 },
/* June leap second */
{ 2015, 6, 30, 23, 59, 59 },
{ 2015, 6, 30, 23, 59, 60 },
{ 2015, 7, 1, 0, 0, 0 },
/* Invalid leap second */
{ 2017, 1, 24, 16, 40, 60 },
/* Dec leap second */
{ 2016, 12, 31, 23, 59, 59 },
{ 2016, 12, 31, 23, 59, 60 },
{ 2017, 1, 1, 0, 0, 0 },
};
#ifdef TIME_T_SIGNED
-1,
-2147483647,
#endif
4294967295,
#endif
1194397640,
0,
2147483647,
-1,
2147483648,
4294967295,
4294967296,
/* June leap second */
1435708799,
1435708799,
1435708800,
/* Invalid leap second - utc_mktime() doesn't mind */
1485276059,
/* Dec leap second */
1483228799,
1483228799,
1483228800,
};
unsigned int i;
time_t t;
bool success;
for (i = 0; i < N_ELEMENTS(input); i++) {
t = utc_mktime(&tm);
(long)t, (long)output[i]));
}
}