X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Futil_test.cc;h=3817a8d08d06438278670f3763546ea39511ca04;hb=5f2a57d1c21c3e8067dfd1f68505b1bf96e1d7c7;hp=5eb3e27f185a70039edf090f39ee19160b131650;hpb=4e411ea97b4dab8a5fa282d1d4cf7971ef1e24ad;p=dcpomatic.git diff --git a/test/util_test.cc b/test/util_test.cc index 5eb3e27f1..3817a8d08 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -88,3 +88,22 @@ BOOST_AUTO_TEST_CASE (divide_with_round_test) BOOST_CHECK_EQUAL (divide_with_round (1000, 500), 2); } + +BOOST_AUTO_TEST_CASE (timecode_test) +{ + DCPTime t = DCPTime::from_seconds (2 * 60 * 60 + 4 * 60 + 31) + DCPTime::from_frames (19, 24); + BOOST_CHECK_EQUAL (t.timecode (24), "02:04:31:19"); +} + +BOOST_AUTO_TEST_CASE (seconds_to_approximate_hms_test) +{ + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1), "1s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2), "2s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (60), "1m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1.5 * 60), "1m 30s"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2 * 60), "2m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (17 * 60 + 20), "17m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1 * 3600), "1h"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (3600 + 40 * 60), "1h 40m"); + BOOST_CHECK_EQUAL (seconds_to_approximate_hms (13 * 3600 + 40 * 60), "14h"); +}