3 #include "ntp_stdlib.h"
4 #include "ntp_calendar.h"
7 #include "test-libntp.h"
11 void test_NoWrapInDateRange(void);
12 void test_NoWrapInDateRangeLeapYear(void);
13 void test_WrapInDateRange(void);
17 ntpcal_set_timefunc(timefunc);
18 settime(1970, 1, 1, 0, 0, 0);
23 ntpcal_set_timefunc(NULL);
27 void test_NoWrapInDateRange(void) {
28 const u_int32 input = 3486372600UL; // 2010-06-24 12:50:00.
29 const u_int32 expected = 3471292800UL; // 2010-01-01 00:00:00
31 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
32 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));
35 void test_NoWrapInDateRangeLeapYear(void) {
36 const u_int32 input = 3549528000UL; // 2012-06-24 12:00:00
37 const u_int32 expected = 3534364800UL; // 2012-01-01 00:00:00
39 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
40 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));
43 void test_WrapInDateRange(void) {
44 const u_int32 input = 19904UL; // 2036-02-07 12:00:00
45 const u_int32 expected = 4291747200UL; // 2036-01-01 00:00:00
47 TEST_ASSERT_EQUAL(expected, calyearstart(input, &nowtime));
48 TEST_ASSERT_EQUAL(expected, calyearstart(input, NULL));