Changeset View
Changeset View
Standalone View
Standalone View
src/test/util_tests.cpp
Show First 20 Lines • Show All 920 Lines • ▼ Show 20 Lines | |||||
/* Check for mingw/wine issue #3494 | /* Check for mingw/wine issue #3494 | ||||
* Remove this test before time.ctime(0xffffffff) == 'Sun Feb 7 07:28:15 2106' | * Remove this test before time.ctime(0xffffffff) == 'Sun Feb 7 07:28:15 2106' | ||||
*/ | */ | ||||
BOOST_AUTO_TEST_CASE(gettime) { | BOOST_AUTO_TEST_CASE(gettime) { | ||||
BOOST_CHECK((GetTime() & ~0xFFFFFFFFLL) == 0); | BOOST_CHECK((GetTime() & ~0xFFFFFFFFLL) == 0); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(util_time_GetTime) { | |||||
SetMockTime(111); | |||||
// Check that mock time does not change after a sleep | |||||
for (const auto &num_sleep : {0, 1}) { | |||||
MilliSleep(num_sleep); | |||||
BOOST_CHECK_EQUAL(111, GetTime()); // Deprecated time getter | |||||
BOOST_CHECK_EQUAL(111, GetTime<std::chrono::seconds>().count()); | |||||
BOOST_CHECK_EQUAL(111000, GetTime<std::chrono::milliseconds>().count()); | |||||
BOOST_CHECK_EQUAL(111000000, | |||||
GetTime<std::chrono::microseconds>().count()); | |||||
} | |||||
SetMockTime(0); | |||||
// Check that system time changes after a sleep | |||||
const auto ms_0 = GetTime<std::chrono::milliseconds>(); | |||||
const auto us_0 = GetTime<std::chrono::microseconds>(); | |||||
MilliSleep(1); | |||||
BOOST_CHECK(ms_0 < GetTime<std::chrono::milliseconds>()); | |||||
BOOST_CHECK(us_0 < GetTime<std::chrono::microseconds>()); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(test_IsDigit) { | BOOST_AUTO_TEST_CASE(test_IsDigit) { | ||||
BOOST_CHECK_EQUAL(IsDigit('0'), true); | BOOST_CHECK_EQUAL(IsDigit('0'), true); | ||||
BOOST_CHECK_EQUAL(IsDigit('1'), true); | BOOST_CHECK_EQUAL(IsDigit('1'), true); | ||||
BOOST_CHECK_EQUAL(IsDigit('8'), true); | BOOST_CHECK_EQUAL(IsDigit('8'), true); | ||||
BOOST_CHECK_EQUAL(IsDigit('9'), true); | BOOST_CHECK_EQUAL(IsDigit('9'), true); | ||||
BOOST_CHECK_EQUAL(IsDigit('0' - 1), false); | BOOST_CHECK_EQUAL(IsDigit('0' - 1), false); | ||||
BOOST_CHECK_EQUAL(IsDigit('9' + 1), false); | BOOST_CHECK_EQUAL(IsDigit('9' + 1), false); | ||||
▲ Show 20 Lines • Show All 559 Lines • Show Last 20 Lines |