catch3
Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.
Clonegit clone https://git.progmasoft.com/catch3
Increased int size for timers to avoid truncations
- Commit
4da655c1b06ec238ed63424bbc0e2a6f80f9d63a- Author
- Phil Nash ·
- Parents
c4d1aa903373
Changes
include/internal/catch_timer.cpp | 9 +++++---- include/internal/catch_timer.h | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/internal/catch_timer.cpp b/include/internal/catch_timer.cpp index a6f37e8e..0057cc39 100644 --- a/include/internal/catch_timer.cpp +++ b/include/internal/catch_timer.cpp @@ -9,6 +9,7 @@ #include "catch_timer.h" #include <chrono> +#include <iostream> namespace Catch { @@ -45,11 +46,11 @@ namespace Catch { void Timer::start() { m_nanoseconds = getCurrentNanosecondsSinceEpoch(); } - auto Timer::getElapsedNanoseconds() const -> unsigned int { - return static_cast<unsigned int>(getCurrentNanosecondsSinceEpoch() - m_nanoseconds); + auto Timer::getElapsedNanoseconds() const -> uint64_t { + return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; } - auto Timer::getElapsedMicroseconds() const -> unsigned int { - return static_cast<unsigned int>(getElapsedNanoseconds()/1000); + auto Timer::getElapsedMicroseconds() const -> uint64_t { + return getElapsedNanoseconds()/1000; } auto Timer::getElapsedMilliseconds() const -> unsigned int { return static_cast<unsigned int>(getElapsedMicroseconds()/1000); diff --git a/include/internal/catch_timer.h b/include/internal/catch_timer.h index 28e1f9db..74ab428e 100644 --- a/include/internal/catch_timer.h +++ b/include/internal/catch_timer.h @@ -19,8 +19,8 @@ namespace Catch { uint64_t m_nanoseconds = 0; public: void start(); - auto getElapsedNanoseconds() const -> unsigned int; - auto getElapsedMicroseconds() const -> unsigned int; + auto getElapsedNanoseconds() const -> uint64_t; + auto getElapsedMicroseconds() const -> uint64_t; auto getElapsedMilliseconds() const -> unsigned int; auto getElapsedSeconds() const -> double; };