summaryrefslogtreecommitdiffstats
path: root/contrib/ntp/tests/libntp/g_ymd2yd.cpp
blob: 7e2599960124077edd1ffb5c8fa04710d02e3968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "g_libntptest.h"

class ymd2ydTest : public libntptest {
};

TEST_F(ymd2ydTest, NonLeapYearFebruary) {
	EXPECT_EQ(31+20, ymd2yd(2010,2,20)); //2010-02-20
}

TEST_F(ymd2ydTest, NonLeapYearJune) {
	int expected = 31+28+31+30+31+18; // 18 June non-leap year
	EXPECT_EQ(expected, ymd2yd(2011,6,18));
}

TEST_F(ymd2ydTest, LeapYearFebruary) {
	EXPECT_EQ(31+20, ymd2yd(2012,2,20)); //2012-02-20 (leap year)
}

TEST_F(ymd2ydTest, LeapYearDecember) {
	// 2012-12-31
	int expected = 31+29+31+30+31+30+31+31+30+31+30+31;
	EXPECT_EQ(expected, ymd2yd(2012,12,31));
}
OpenPOWER on IntegriCloud