X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Futil_test.cc;h=39cc0e6bf7df07956b56191e88af6465ee92db71;hb=73f52e94953848c696725defd3d7f5c4c30707e2;hp=3373bf86b59e468bed2b97736987f858cd477b54;hpb=09806bc8d6a48fc79d923ec1cdf6f90176bf8b6a;p=dcpomatic.git diff --git a/test/util_test.cc b/test/util_test.cc index 3373bf86b..39cc0e6bf 100644 --- a/test/util_test.cc +++ b/test/util_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,6 +17,10 @@ */ +/** @file test/util_test.cc + * @brief Test various utility methods. + */ + #include #include "lib/util.h" #include "lib/exceptions.h" @@ -57,15 +61,18 @@ BOOST_AUTO_TEST_CASE (md5_digest_test) /* Straightforward test of DCPTime::round_up */ BOOST_AUTO_TEST_CASE (dcptime_round_up_test) { - BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 2), 0); - BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 2), 2); - BOOST_CHECK_EQUAL (DCPTime (2).round_up (DCPTime::HZ / 2), 2); - BOOST_CHECK_EQUAL (DCPTime (3).round_up (DCPTime::HZ / 2), 4); + BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 2), DCPTime (0)); + BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 2), DCPTime (2)); + BOOST_CHECK_EQUAL (DCPTime (2).round_up (DCPTime::HZ / 2), DCPTime (2)); + BOOST_CHECK_EQUAL (DCPTime (3).round_up (DCPTime::HZ / 2), DCPTime (4)); - BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 42), 0); - BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 42), 42); - BOOST_CHECK_EQUAL (DCPTime (42).round_up (DCPTime::HZ / 42), 42); - BOOST_CHECK_EQUAL (DCPTime (43).round_up (DCPTime::HZ / 42), 84); + BOOST_CHECK_EQUAL (DCPTime (0).round_up (DCPTime::HZ / 42), DCPTime (0)); + BOOST_CHECK_EQUAL (DCPTime (1).round_up (DCPTime::HZ / 42), DCPTime (42)); + BOOST_CHECK_EQUAL (DCPTime (42).round_up (DCPTime::HZ / 42), DCPTime (42)); + BOOST_CHECK_EQUAL (DCPTime (43).round_up (DCPTime::HZ / 42), DCPTime (84)); + + /* Check that rounding up to non-integer frame rates works */ + BOOST_CHECK_EQUAL (DCPTime (45312).round_up (29.976), DCPTime (48045)); } @@ -81,3 +88,9 @@ 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"); +}