2 #include "ntp_calendar.h"
5 void test_DateGivenMonthDay(void);
6 void test_DateGivenYearDay(void);
7 void test_DateLeapYear(void);
8 void test_WraparoundDateIn2036(void);
11 test_DateGivenMonthDay(void) {
12 // 2010-06-24 12:50:00
13 struct calendar input = {2010, 0, 6, 24, 12, 50, 0};
15 u_long expected = 3486372600UL; // This is the timestamp above.
17 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
21 test_DateGivenYearDay(void) {
22 // 2010-06-24 12:50:00
23 // This is the 175th day of 2010.
24 struct calendar input = {2010, 175, 0, 0, 12, 50, 0};
26 u_long expected = 3486372600UL; // This is the timestamp above.
28 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));
32 test_DateLeapYear(void) {
33 // 2012-06-24 12:00:00
34 // This is the 176th day of 2012 (since 2012 is a leap year).
35 struct calendar inputYd = {2012, 176, 0, 0, 12, 00, 00};
36 struct calendar inputMd = {2012, 0, 6, 24, 12, 00, 00};
38 u_long expected = 3549528000UL;
40 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputYd));
41 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&inputMd));
45 test_WraparoundDateIn2036(void) {
46 // 2036-02-07 06:28:16
47 // This is (one) wrapping boundary where we go from ULONG_MAX to 0.
48 struct calendar input = {2036, 0, 2, 7, 6, 28, 16};
50 u_long expected = 0UL;
52 TEST_ASSERT_EQUAL_UINT(expected, caltontp(&input));