From b8977c4dd0fd8ebeab154fa3bf91b0873537495b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 26 Sep 2015 23:25:20 -0400 Subject: [PATCH] Test: Added more ISO8601d tests --- test/iso8601d.t.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/test/iso8601d.t.cpp b/test/iso8601d.t.cpp index 06b7709e6..2aa098532 100644 --- a/test/iso8601d.t.cpp +++ b/test/iso8601d.t.cpp @@ -71,7 +71,7 @@ void testParse ( //////////////////////////////////////////////////////////////////////////////// int main (int argc, char** argv) { - UnitTest t (860); + UnitTest t (869); ISO8601d iso; std::string::size_type start = 0; @@ -240,6 +240,22 @@ int main (int argc, char** argv) t.ok (now <= tomorrow, "now <= tomorrow"); t.ok (now < tomorrow, "now < tomorrow"); + // Date::Date ("now") + context.config.set ("weekstart", "monday"); + ISO8601d relative_now; + t.ok (relative_now.sameHour (now), "Date ().sameHour (Date (now))"); + t.ok (relative_now.sameDay (now), "Date ().sameDay (Date (now))"); + t.ok (relative_now.sameWeek (now), "Date ().sameWeek (Date (now))"); + t.ok (relative_now.sameMonth (now), "Date ().sameMonth (Date (now))"); + t.ok (relative_now.sameYear (now), "Date ().sameYear (Date (now))"); + + // Validity. + t.ok (ISO8601d::valid (2, 29, 2008), "valid: 2/29/2008"); + t.notok (ISO8601d::valid (2, 29, 2007), "invalid: 2/29/2007"); + + t.ok (ISO8601d::valid (366, 2008), "valid: 366 days in 2008"); + t.notok (ISO8601d::valid (366, 2007), "invalid: 366 days in 2007"); + // Leap year. t.ok (ISO8601d::leapYear (2008), "2008 is a leap year"); t.notok (ISO8601d::leapYear (2007), "2007 is not a leap year");