Plot video and subtitle on one track and audio on the rest in the timeline.
[dcpomatic.git] / test / dcpomatic_time_test.cc
index 4462ae870f59ce2dfa1738e0fd099abbda379e3b..ca29d8839346fd2013527d25aeee337b580c616b 100644 (file)
@@ -28,8 +28,7 @@ BOOST_AUTO_TEST_CASE (dcpomatic_time_test)
        for (int64_t i = 0; i < 62000; i += 2000) {
                DCPTime d (i);
                ContentTime c (d, frc);
-               std::cout << i << " " << d << " " << c << " " << c.frames (24.0) << " " << j << "\n";
-               BOOST_CHECK_EQUAL (c.frames (24.0), j);
+               BOOST_CHECK_EQUAL (c.frames_floor (24.0), j);
                ++k;
                if (k == 2) {
                        ++j;
@@ -37,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));
+}