Improve approximate time reporting a bit (#383).
[dcpomatic.git] / test / util_test.cc
index 750023d9f1a689bb4414706b66c352a4b6cda2d8..40a2835f1515f68a47ba5b9981a812778ad10295 100644 (file)
@@ -66,3 +66,16 @@ BOOST_AUTO_TEST_CASE (divide_with_round_test)
 
        BOOST_CHECK_EQUAL (divide_with_round (1000, 500), 2);
 }
+
+BOOST_AUTO_TEST_CASE (seconds_to_approximate_hms_test)
+{
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1), "1 second");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2), "2 seconds");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (60), "1 minute");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1.5 * 60), "1 minute 30 seconds");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (2 * 60), "2 minutes");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (17 * 60 + 20), "17 minutes");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (1 * 3600), "1 hour");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (3600 + 40 * 60), "1 hour 40 minutes");
+       BOOST_CHECK_EQUAL (seconds_to_approximate_hms (13 * 3600 + 40 * 60), "14 hours");
+}