diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-24 00:15:06 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-24 00:15:06 +0000 |
| commit | 794396aa29061894ea359a6f30aa0f759a1f1b74 (patch) | |
| tree | 46bbf0dfacac7caa7d628d409de3c6e58bdb835a /test | |
| parent | 64058945e21e7b5f3c688f5563cefdd8db1259ef (diff) | |
Add test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/dcpomatic_time_test.cc | 33 |
1 files changed, 33 insertions, 0 deletions
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<DCPTime> a (DCPTime (0), DCPTime (4)); + TimePeriod<DCPTime> b (DCPTime (4), DCPTime (8)); + BOOST_CHECK (!a.overlaps (b)); + + /* Some more obvious non-overlaps */ + a = TimePeriod<DCPTime> (DCPTime (0), DCPTime (4)); + b = TimePeriod<DCPTime> (DCPTime (5), DCPTime (8)); + BOOST_CHECK (!a.overlaps (b)); + + /* Some overlaps */ + a = TimePeriod<DCPTime> (DCPTime (0), DCPTime (4)); + b = TimePeriod<DCPTime> (DCPTime (3), DCPTime (8)); + BOOST_CHECK (a.overlaps (b)); + a = TimePeriod<DCPTime> (DCPTime (1), DCPTime (9)); + b = TimePeriod<DCPTime> (DCPTime (0), DCPTime (10)); + BOOST_CHECK (a.overlaps (b)); +} |
