summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-07-18 10:37:51 +0100
committerCarl Hetherington <cth@carlh.net>2017-07-18 10:38:17 +0100
commita25cc3fda26e2bbc6b1c3786cc7f2ed7141a29f0 (patch)
tree763e292124b43b8c652bb4d34eaae5e14e8236f6 /test
parent4f6f03dc72d9cd24f3e4b2d856c5ccb66bda3930 (diff)
Fix Time::add which was broken when adding times with different rates.
Diffstat (limited to 'test')
-rw-r--r--test/time_test.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/time_test.cc b/test/time_test.cc
index a4dae50..3fa9cb5 100644
--- a/test/time_test.cc
+++ b/test/time_test.cc
@@ -20,6 +20,7 @@
#include "sub_time.h"
#include "exceptions.h"
#include <boost/test/unit_test.hpp>
+#include <iostream>
/* Check time construction */
BOOST_AUTO_TEST_CASE (time_construction_test)
@@ -72,3 +73,11 @@ BOOST_AUTO_TEST_CASE (time_other_test)
BOOST_CHECK_THROW (sub::Time::from_hmsf (2, 1, 58, 4).all_as_seconds(), sub::UnknownFrameRateError);
BOOST_CHECK_CLOSE (sub::Time::from_hmsf (2, 1, 58, 4, sub::Rational (24, 1)).all_as_seconds(), 7318.1667, 0.001);
}
+
+/* Check an addition case that gave an odd result */
+BOOST_AUTO_TEST_CASE (time_add_test)
+{
+ sub::Time t = sub::Time::from_hmsf (0, 4, 8, 208, sub::Rational(1000, 1));
+ t.add (sub::Time::from_frames(54641, sub::Rational(24, 1)));
+ BOOST_CHECK_EQUAL (t, sub::Time::from_hmsf (0, 42, 4, 916, sub::Rational(1000, 1)));
+}