diff --git a/catch_tests/utils-and-constants/ECSUtilsTests.cpp b/catch_tests/utils-and-constants/ECSUtilsTests.cpp index 135d2e91..d07496ed 100644 --- a/catch_tests/utils-and-constants/ECSUtilsTests.cpp +++ b/catch_tests/utils-and-constants/ECSUtilsTests.cpp @@ -16,6 +16,18 @@ namespace { }; } +// run a bunch of asserts, try to catch a leap backwards +TEST_CASE("getTimeStamp monotonic time fuzz test") { + auto prevTime = getTimeStamp(); + + for (int i = 0; i < 20; i++){ + auto curTime = getTimeStamp(); + + assert(prevTime <= curTime); + prevTime = curTime; + } +} + TEST_CASE("make_vector_unique", "[unit]") { std::vector> result = make_vector_unique(std::make_unique(21312), std::make_unique(45342), @@ -34,4 +46,4 @@ TEST_CASE("make_vector_unique", "[unit]") { TEST_CASE("filterDoubleNan", "[unit]") { REQUIRE_THAT(filterDoubleNan(1230.0), Catch::WithinRel(1230.0, 0.1)); REQUIRE_THAT(filterDoubleNan(std::nan("")), Catch::WithinRel(0.0, 0.1)); -} \ No newline at end of file +} diff --git a/src/utils/ECSUtils.cpp b/src/utils/ECSUtils.cpp index eded94ca..66b1da8d 100644 --- a/src/utils/ECSUtils.cpp +++ b/src/utils/ECSUtils.cpp @@ -43,7 +43,7 @@ std::string get_date(){ uint64_t getTimeStamp() { return std::chrono::duration_cast( - std::chrono::system_clock::now().time_since_epoch() + std::chrono::steady_clock::now().time_since_epoch() ).count(); } @@ -63,4 +63,4 @@ double filterDoubleNan(double check) { #ifdef _MSC_VER #undef _CRT_SECURE_NO_WARNINGS -#endif \ No newline at end of file +#endif