diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-24 17:38:46 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-24 17:38:46 +0100 |
| commit | 208f598e2af83fe7be465680806c79af3da825d3 (patch) | |
| tree | 295a1c34e7f11a8c6f2a0aee0ab57036a55f809f /test | |
| parent | 7002892583b9e008a1bd3469c6db859292927286 (diff) | |
More tests and fix MetricTime.
Diffstat (limited to 'test')
| -rw-r--r-- | test/time_test.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/time_test.cc b/test/time_test.cc index a42fc9d..a244377 100644 --- a/test/time_test.cc +++ b/test/time_test.cc @@ -22,11 +22,34 @@ #include "frame_time.h" #include "convert_time.h" +/* Check time construction */ +BOOST_AUTO_TEST_CASE (time_construction_test) +{ + { + sub::MetricTime t (3, 5, 7, 40); + BOOST_CHECK_EQUAL (t.hours(), 3); + BOOST_CHECK_EQUAL (t.minutes(), 5); + BOOST_CHECK_EQUAL (t.seconds(), 7); + BOOST_CHECK_EQUAL (t.milliseconds(), 40); + } + + { + sub::MetricTime t (591353, 1, 2, 3); + BOOST_CHECK_EQUAL (t.hours(), 591353); + BOOST_CHECK_EQUAL (t.minutes(), 1); + BOOST_CHECK_EQUAL (t.seconds(), 2); + BOOST_CHECK_EQUAL (t.milliseconds(), 3); + } +} + /* Check time conversions */ -BOOST_AUTO_TEST_CASE (time_test) +BOOST_AUTO_TEST_CASE (time_conversion_test) { + /* 40ms = 1 frame at 25fps */ BOOST_CHECK_EQUAL (metric_to_frame (sub::MetricTime (3, 5, 7, 40), 25), sub::FrameTime (3, 5, 7, 1)); BOOST_CHECK_EQUAL (frame_to_metric (sub::FrameTime (3, 5, 7, 1), 25), sub::MetricTime (3, 5, 7, 40)); + + /* 120ms = 3 frames at 25fps */ BOOST_CHECK_EQUAL (metric_to_frame (sub::MetricTime (3, 5, 7, 120), 25), sub::FrameTime (3, 5, 7, 3)); BOOST_CHECK_EQUAL (frame_to_metric (sub::FrameTime (3, 5, 7, 3), 25), sub::MetricTime (3, 5, 7, 120)); } |
