1 #include "g_libntptest.h"
3 class calyearstartTest : public libntptest {
6 virtual void TearDown();
9 void calyearstartTest::SetUp()
11 ntpcal_set_timefunc(timefunc);
12 settime(1970, 1, 1, 0, 0, 0);
15 void calyearstartTest::TearDown()
17 ntpcal_set_timefunc(NULL);
21 TEST_F(calyearstartTest, NoWrapInDateRange) {
22 const u_int32 input = 3486372600UL; // 2010-06-24 12:50:00.
23 const u_int32 expected = 3471292800UL; // 2010-01-01 00:00:00
25 EXPECT_EQ(expected, calyearstart(input, &nowtime));
26 EXPECT_EQ(expected, calyearstart(input, NULL));
29 TEST_F(calyearstartTest, NoWrapInDateRangeLeapYear) {
30 const u_int32 input = 3549528000UL; // 2012-06-24 12:00:00
31 const u_int32 expected = 3534364800UL; // 2012-01-01 00:00:00
33 EXPECT_EQ(expected, calyearstart(input, &nowtime));
34 EXPECT_EQ(expected, calyearstart(input, NULL));
37 TEST_F(calyearstartTest, WrapInDateRange) {
38 const u_int32 input = 19904UL; // 2036-02-07 12:00:00
39 const u_int32 expected = 4291747200UL; // 2036-01-01 00:00:00
41 EXPECT_EQ(expected, calyearstart(input, &nowtime));
42 EXPECT_EQ(expected, calyearstart(input, NULL));