Skip to content

Commit c8c827b

Browse files
committed
test years(Period)
1 parent bfa4fab commit c8c827b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test-suite/period.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ BOOST_AUTO_TEST_CASE(testOperators) {
140140
BOOST_TEST(p == Period(4, Days));
141141
}
142142

143+
BOOST_AUTO_TEST_CASE(testConvertToYears) {
144+
BOOST_TEST_MESSAGE("Testing converting periods to years...");
145+
146+
BOOST_TEST(years(Period(0, Years)) == 0);
147+
BOOST_TEST(years(Period(1, Years)) == 1);
148+
BOOST_TEST(years(Period(5, Years)) == 5);
149+
150+
const auto tol = boost::test_tools::tolerance(1e-15);
151+
BOOST_TEST(years(Period(1, Months)) == 1.0/12.0, tol);
152+
BOOST_TEST(years(Period(8, Months)) == 8.0/12.0, tol);
153+
BOOST_TEST(years(Period(12, Months)) == 1);
154+
BOOST_TEST(years(Period(18, Months)) == 1.5, tol);
155+
}
156+
143157
BOOST_AUTO_TEST_CASE(testNormalization) {
144158

145159
BOOST_TEST_MESSAGE("Testing period normalization...");

0 commit comments

Comments
 (0)