1 #include "g_libntptest.h"
4 #include "ntp_calendar.h"
7 class caltontpTest : public libntptest {
10 TEST_F(caltontpTest, DateGivenMonthDay) {
11 // 2010-06-24 12:50:00
12 calendar input = {2010, 0, 6, 24, 12, 50, 0};
14 u_long expected = 3486372600UL; // This is the timestamp above.
16 EXPECT_EQ(expected, caltontp(&input));
19 TEST_F(caltontpTest, DateGivenYearDay) {
20 // 2010-06-24 12:50:00
21 // This is the 175th day of 2010.
22 calendar input = {2010, 175, 0, 0, 12, 50, 0};
24 u_long expected = 3486372600UL; // This is the timestamp above.
26 EXPECT_EQ(expected, caltontp(&input));
29 TEST_F(caltontpTest, DateLeapYear) {
30 // 2012-06-24 12:00:00
31 // This is the 176th day of 2012 (since 2012 is a leap year).
32 calendar inputYd = {2012, 176, 0, 0, 12, 00, 00};
33 calendar inputMd = {2012, 0, 6, 24, 12, 00, 00};
35 u_long expected = 3549528000UL;
37 EXPECT_EQ(expected, caltontp(&inputYd));
38 EXPECT_EQ(expected, caltontp(&inputMd));
41 TEST_F(caltontpTest, WraparoundDateIn2036) {
42 // 2036-02-07 06:28:16
43 // This is (one) wrapping boundary where we go from ULONG_MAX to 0.
44 calendar input = {2036, 0, 2, 7, 6, 28, 16};
46 u_long expected = 0UL;
48 EXPECT_EQ(expected, caltontp(&input));