freebsd-dev/tests/libntp/humandate.c

43 lines
747 B
C
Raw Normal View History

#include "config.h"
#include "ntp_calendar.h"
#include "ntp_stdlib.h"
#include "unity.h"
2015-10-21 19:16:13 +00:00
void test_RegularTime(void);
void test_CurrentTime(void);
void
test_RegularTime(void)
{
time_t sample = 1276601278;
char expected[15];
2015-10-21 19:16:13 +00:00
struct tm* tm;
2015-10-21 19:16:13 +00:00
tm = localtime(&sample);
TEST_ASSERT_TRUE(time != NULL);
2015-10-21 19:16:13 +00:00
snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
}
2015-10-21 19:16:13 +00:00
void
test_CurrentTime(void)
{
time_t sample;
char expected[15];
2015-10-21 19:16:13 +00:00
struct tm* tm;
time(&sample);
2015-10-21 19:16:13 +00:00
tm = localtime(&sample);
TEST_ASSERT_TRUE(time != NULL);
2015-10-21 19:16:13 +00:00
snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
}