21 #include <boost/test/unit_test.hpp>
30 QChar mu = QChar(0x03BC);
44 BOOST_AUTO_TEST_SUITE(UtilTest)
204 using namespace std::placeholders;
208 BOOST_CHECK_EQUAL(fmt(
ts( 0), 0),
"+0:00");
209 BOOST_CHECK_EQUAL(fmt(
ts( 1), 0),
"+0:01");
210 BOOST_CHECK_EQUAL(fmt(
ts( 59), 0),
"+0:59");
211 BOOST_CHECK_EQUAL(fmt(
ts( 60), 0),
"+1:00");
212 BOOST_CHECK_EQUAL(fmt(
ts( -1), 0),
"-0:01");
213 BOOST_CHECK_EQUAL(fmt(
ts( -59), 0),
"-0:59");
214 BOOST_CHECK_EQUAL(fmt(
ts( -60), 0),
"-1:00");
215 BOOST_CHECK_EQUAL(fmt(
ts( 100), 0),
"+1:40");
216 BOOST_CHECK_EQUAL(fmt(
ts( -100), 0),
"-1:40");
217 BOOST_CHECK_EQUAL(fmt(
ts( 4000), 0),
"+1:06:40");
218 BOOST_CHECK_EQUAL(fmt(
ts(-4000), 0),
"-1:06:40");
219 BOOST_CHECK_EQUAL(fmt(
ts(12000), 0),
"+3:20:00");
220 BOOST_CHECK_EQUAL(fmt(
ts(15000), 0),
"+4:10:00");
221 BOOST_CHECK_EQUAL(fmt(
ts(20000), 0),
"+5:33:20");
222 BOOST_CHECK_EQUAL(fmt(
ts(25000), 0),
"+6:56:40");
224 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 0),
"+123:04:05:06");
225 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 1),
"+123:04:05:06.0");
226 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 2),
"+123:04:05:06.01");
227 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 3),
"+123:04:05:06.007");
228 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 4),
"+123:04:05:06.007 0");
229 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 5),
"+123:04:05:06.007 01");
230 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 6),
"+123:04:05:06.007 008");
231 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 7),
"+123:04:05:06.007 008 0");
232 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 8),
"+123:04:05:06.007 008 01");
233 BOOST_CHECK_EQUAL(fmt(
ts(
"10641906.007008009"), 9),
"+123:04:05:06.007 008 009");
240 BOOST_AUTO_TEST_SUITE_END()
QString format_time_si(const Timestamp &v, SIPrefix prefix, unsigned int precision, QString unit, bool sign)
QString format_time_si_adjusted(const Timestamp &t, SIPrefix prefix, unsigned precision, QString unit, bool sign)
int exponent(SIPrefix prefix)
Returns the exponent that corresponds to a given prefix.
BOOST_AUTO_TEST_CASE(exponent_test)
QString format_time_minutes(const Timestamp &t, signed precision, bool sign)
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 24 >, boost::multiprecision::et_off > Timestamp
Timestamp type providing yoctosecond resolution.