]> CyberLeo.Net >> Repos - FreeBSD/releng/9.3.git/blob - contrib/ntp/tests/libntp/humandate.c
o Fix invalid TCP checksums with pf(4). [EN-16:02.pf]
[FreeBSD/releng/9.3.git] / contrib / ntp / tests / libntp / humandate.c
1 #include "config.h"
2
3 #include "ntp_calendar.h"
4 #include "ntp_stdlib.h"
5
6 #include "unity.h"
7
8 void setUp(void);
9 void test_RegularTime(void);
10 void test_CurrentTime(void);
11
12
13 void
14 setUp(void)
15 {
16         init_lib();
17
18         return;
19 }
20
21
22 void
23 test_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
39 void
40 test_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 }