diff options
Diffstat (limited to 'tests/libntp/ymd2yd.cpp')
-rw-r--r-- | tests/libntp/ymd2yd.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/libntp/ymd2yd.cpp b/tests/libntp/ymd2yd.cpp new file mode 100644 index 0000000..e6f46f8 --- /dev/null +++ b/tests/libntp/ymd2yd.cpp @@ -0,0 +1,23 @@ +#include "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)); +} |