3 #include "ntp_calendar.h"
6 test_DateGivenMonthDay(void) {
8 struct calendar input = {2010, 0, 6, 24, 12, 50, 0};
10 u_long expected = 3486372600UL; // This is the timestamp above.
12 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
16 test_DateGivenYearDay(void) {
17 // 2010-06-24 12:50:00
18 // This is the 175th day of 2010.
19 struct calendar input = {2010, 175, 0, 0, 12, 50, 0};
21 u_long expected = 3486372600UL; // This is the timestamp above.
23 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
27 test_DateLeapYear(void) {
28 // 2012-06-24 12:00:00
29 // This is the 176th day of 2012 (since 2012 is a leap year).
30 struct calendar inputYd = {2012, 176, 0, 0, 12, 00, 00};
31 struct calendar inputMd = {2012, 0, 6, 24, 12, 00, 00};
33 u_long expected = 3549528000UL;
35 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputYd));
36 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputMd));
40 test_WraparoundDateIn2036(void) {
41 // 2036-02-07 06:28:16
42 // This is (one) wrapping boundary where we go from ULONG_MAX to 0.
43 struct calendar input = {2036, 0, 2, 7, 6, 28, 16};
45 u_long expected = 0UL;
47 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));