]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/ntp/tests/libntp/humandate.c
Upgrade NTP to 4.2.8p4.
[FreeBSD/releng/10.2.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 test_RegularTime(void);
9 void test_CurrentTime(void);
10
11
12 void
13 test_RegularTime(void)
14 {
15         time_t sample = 1276601278;
16         char expected[15];
17         struct tm* tm;
18
19         tm = localtime(&sample);
20         TEST_ASSERT_TRUE(time != NULL);
21
22         snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
23
24         TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
25 }
26
27 void
28 test_CurrentTime(void)
29 {
30         time_t sample;
31         char expected[15];
32         struct tm* tm;
33
34         time(&sample);
35
36         tm = localtime(&sample);
37         TEST_ASSERT_TRUE(time != NULL);
38
39         snprintf(expected, 15, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min, tm->tm_sec);
40
41         TEST_ASSERT_EQUAL_STRING(expected, humantime(sample));
42 }