/* Copyright (c) 2009-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "time-util.h"
#include <time.h>
static void test_timeval_cmp(void)
{
static const struct {
int output;
} tests[] = {
{
.tv1 = { 0, 0 },
.tv2 = { 0, 0 },
.output = 0,
}, {
.output = 0,
}, {
.tv1 = { 0, 0 },
.tv2 = { 0, 1 },
.output = -1,
}, {
.tv1 = { 0, 0 },
.tv2 = { 1, 0 },
.output = -1,
}, {
.tv1 = { 0, 999999 },
.tv2 = { 1, 0 },
.output = -1,
}, {
.tv1 = { 1, 0 },
.output = -1,
}, {
.output = -1,
}
};
unsigned int i;
test_begin("timeval_cmp()");
for (i = 0; i < N_ELEMENTS(tests); i++) {
}
test_end();
}
static void test_timeval_cmp_margin(void)
{
static const struct {
unsigned int margin;
int output;
} tests[] = {
{
.tv1 = { 0, 0 },
.tv2 = { 0, 0 },
.output = 0,
},{
.output = 0,
},{
.tv1 = { 0, 0 },
.tv2 = { 0, 1 },
.output = -1,
},{
.tv1 = { 0, 0 },
.tv2 = { 1, 0 },
.output = -1,
},{
.tv1 = { 0, 999999 },
.tv2 = { 1, 0 },
.output = -1,
},{
.tv1 = { 1, 0 },
.output = -1,
},{
.output = -1,
},{
.tv1 = { 0, 999999 },
.tv2 = { 1, 0 },
.margin = 1,
.output = 0,
},{
.tv1 = { 1, 0 },
.margin = 1,
.output = 0,
},{
.tv1 = { 0, 999998 },
.tv2 = { 1, 0 },
.margin = 1,
.output = -1,
},{
.tv1 = { 1, 0 },
.margin = 1,
.output = -1,
},{
.tv1 = { 0, 998000 },
.tv2 = { 1, 0 },
.margin = 2000,
.output = 0,
},{
.tv1 = { 1, 0 },
.margin = 2000,
.output = 0,
},{
.tv1 = { 0, 997999 },
.tv2 = { 1, 0 },
.margin = 2000,
.output = -1,
},{
.tv1 = { 1, 0 },
.margin = 2000,
.output = -1,
},{
.tv1 = { 0, 1 },
.tv2 = { 1, 0 },
.margin = 999999,
.output = 0,
},{
.tv1 = { 1, 0 },
.margin = 999999,
.output = 0,
},{
.tv1 = { 0, 0 },
.tv2 = { 1, 0 },
.margin = 999999,
.output = -1,
},{
.tv1 = { 1, 0 },
.tv2 = { 2, 0 },
.margin = 999999,
.output = -1,
},{
.tv1 = { 10, 0 },
.margin = 1500000,
.output = 0,
},{
.tv2 = { 10, 0 },
.margin = 1500000,
.output = 0,
},{
.tv1 = { 10, 0 },
.margin = 1500000,
.output = -1,
},{
.tv2 = { 10, 0 },
.margin = 1500000,
.output = -1,
},{
.margin = 2000,
.output = 0,
}
};
unsigned int i;
test_begin("timeval_cmp_margin()");
for (i = 0; i < N_ELEMENTS(tests); i++) {
}
test_end();
}
static void test_timeval_diff(void)
{
{ 1, 0 }, { 0, 999999 },
{ 1, 0 }, { 0, 999001 },
{ 1, 1 }, { 0, 999001 },
{ 2, 1 }, { 1, 0 },
};
static int output[] = {
1,
999,
1000,
1000001,
999999
};
unsigned int i;
long long udiff;
int mdiff;
test_begin("timeval_diff_*()");
}
test_end();
}
static void test_time_to_local_day_start(void)
{
/* Try this around days when DST changes in some of the more popular
timezones. If that works, everything else probably works too. */
/* Europe winter -> summer */
/* Europe summer -> winter */
/* USA winter -> summer */
/* USA summer -> winter */
/* (some of) Australia summer -> winter */
/* (some of) Australia winter -> summer */
};
time_t t;
test_begin("time_to_local_day_start()");
for (unsigned i = 0; i < N_ELEMENTS(tests); i++) {
t = time_to_local_day_start(t);
}
test_end();
}
{
/* %G:%H:%M:%S */
/* %G - ISO 8601 year */
unsigned v;
/* %H - hour from 00 to 23 */
/* %M - minute from 00 to 59 */
/* %S - second from 00 to 60 */
}
static void test_strftime_now(void)
{
test_begin("t_strftime and variants now");
test_end();
}
static void test_strftime_fixed(void)
{
test_begin("t_strftime and variants fixed timestamp");
test_end();
}
void test_time_util(void)
{
}