1#include "config.h"
2
3#include "ntp_calendar.h"
4#include "ntp_stdlib.h"
5
6#include "unity.h"
7
8void setUp(void);
9void test_RegularTime(void);
10void test_CurrentTime(void);
11
12
13void
14setUp(void)
15{
16	init_lib();
17
18	return;
19}
20
21
22void
23test_RegularTime(void)
24{
25	time_t sample = 1276601278;
26	char expected[15];
27	struct tm* tm;
28
29	tm = localtime(&sample);
30	TEST_ASSERT_TRUE(tm != NULL);
31
32	snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
33
34	TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
35
36	return;
37}
38
39void
40test_CurrentTime(void)
41{
42	time_t sample;
43	char expected[15];
44	struct tm* tm;
45
46	time(&sample);
47
48	tm = localtime(&sample);
49	TEST_ASSERT_TRUE(tm != NULL);
50
51	snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
52
53	TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
54
55	return;
56}
57