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