X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Futil_test.cc;h=5eb3e27f185a70039edf090f39ee19160b131650;hb=3574212ee42b2bd924eb95d5c0f4f69ec9e0a2f0;hp=3373bf86b59e468bed2b97736987f858cd477b54;hpb=09806bc8d6a48fc79d923ec1cdf6f90176bf8b6a;p=dcpomatic.git diff --git a/test/util_test.cc b/test/util_test.cc index 3373bf86b..5eb3e27f1 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)); }