From 794396aa29061894ea359a6f30aa0f759a1f1b74 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 24 Feb 2016 00:15:06 +0000 Subject: [PATCH] Add test. --- test/dcpomatic_time_test.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/dcpomatic_time_test.cc b/test/dcpomatic_time_test.cc index 2b42d22b8..ca29d8839 100644 --- a/test/dcpomatic_time_test.cc +++ b/test/dcpomatic_time_test.cc @@ -36,3 +36,36 @@ BOOST_AUTO_TEST_CASE (dcpomatic_time_test) } } } + +BOOST_AUTO_TEST_CASE (dcpomatic_time_period_overlaps_test) +{ + /* Taking times as the start of a sampling interval + + |--|--|--|--|--|--|--|--|--|--| + 0 1 2 3 4 5 6 7 8 9 | + |--|--|--|--|--|--|--|--|--|--| + + <------a----><----b-----> + + and saying `from' is the start of the first sampling + interval and `to' is the start of the interval after + the period... a and b do not overlap. + */ + + TimePeriod a (DCPTime (0), DCPTime (4)); + TimePeriod b (DCPTime (4), DCPTime (8)); + BOOST_CHECK (!a.overlaps (b)); + + /* Some more obvious non-overlaps */ + a = TimePeriod (DCPTime (0), DCPTime (4)); + b = TimePeriod (DCPTime (5), DCPTime (8)); + BOOST_CHECK (!a.overlaps (b)); + + /* Some overlaps */ + a = TimePeriod (DCPTime (0), DCPTime (4)); + b = TimePeriod (DCPTime (3), DCPTime (8)); + BOOST_CHECK (a.overlaps (b)); + a = TimePeriod (DCPTime (1), DCPTime (9)); + b = TimePeriod (DCPTime (0), DCPTime (10)); + BOOST_CHECK (a.overlaps (b)); +} -- 2.30.2