RepetitiveInterval: fix comparison
Change-Id: Ibbe5bae6da038b6a8097dc0db692ed5627dfd439
Refs: #3533
diff --git a/tests/unit-tests/repetitive-interval.t.cpp b/tests/unit-tests/repetitive-interval.t.cpp
index 65ac8ae..51abdf8 100644
--- a/tests/unit-tests/repetitive-interval.t.cpp
+++ b/tests/unit-tests/repetitive-interval.t.cpp
@@ -200,6 +200,50 @@
BOOST_CHECK(repetitiveInterval3.getRepeatUnit() == RepetitiveInterval::RepeatUnit::DAY);
}
+static bool
+check(const RepetitiveInterval& small, const RepetitiveInterval& big)
+{
+ return (small < big && !(big < small));
+}
+
+BOOST_AUTO_TEST_CASE(Comparison)
+{
+ BOOST_CHECK(check(RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY),
+ RepetitiveInterval(from_iso_string("20150826T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY)));
+
+ BOOST_CHECK(check(RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY),
+ RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 6, 10, 2, RepetitiveInterval::RepeatUnit::DAY)));
+
+ BOOST_CHECK(check(RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY),
+ RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 11, 2, RepetitiveInterval::RepeatUnit::DAY)));
+
+ BOOST_CHECK(check(RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY),
+ RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 3, RepetitiveInterval::RepeatUnit::DAY)));
+
+ BOOST_CHECK(check(RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::DAY),
+ RepetitiveInterval(from_iso_string("20150825T000000"),
+ from_iso_string("20150828T000000"),
+ 5, 10, 2, RepetitiveInterval::RepeatUnit::MONTH)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests