diff options
| author | Martin Hořeňovský | 2021-12-02 16:25:11 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2021-12-06 20:42:51 +0100 |
| commit | dcf9479c85f4fbd1aa6a296ff81fff235c48e0c1 (patch) | |
| tree | 2ab53893f7f66fd7c765c68e3c96598fe70c2799 /src/catch2 | |
| parent | c49faa62dd0bdc4f71412c63ef161b7231ae2ab4 (diff) | |
| download | catch3-dcf9479c85f4fbd1aa6a296ff81fff235c48e0c1.tar.gz | |
Counts internally use uint64_t instead of size_t
This ensures that even for 32 bit platforms, the assertion count
should not plausibly overflow.
Diffstat (limited to 'src/catch2')
| -rw-r--r-- | src/catch2/catch_totals.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/catch_totals.hpp | 9 | ||||
| -rw-r--r-- | src/catch2/internal/catch_string_manip.hpp | 4 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_compact.cpp | 2 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_console.cpp | 10 |
5 files changed, 14 insertions, 13 deletions
diff --git a/src/catch2/catch_totals.cpp b/src/catch2/catch_totals.cpp index a283c658..14a23869 100644 --- a/src/catch2/catch_totals.cpp +++ b/src/catch2/catch_totals.cpp @@ -24,7 +24,7 @@ namespace Catch { return *this; } - std::size_t Counts::total() const { + std::uint64_t Counts::total() const { return passed + failed + failedButOk; } bool Counts::allPassed() const { diff --git a/src/catch2/catch_totals.hpp b/src/catch2/catch_totals.hpp index 76d6ae47..a062319c 100644 --- a/src/catch2/catch_totals.hpp +++ b/src/catch2/catch_totals.hpp @@ -9,6 +9,7 @@ #define CATCH_TOTALS_HPP_INCLUDED #include <cstddef> +#include <cstdint> namespace Catch { @@ -16,13 +17,13 @@ namespace Catch { Counts operator - ( Counts const& other ) const; Counts& operator += ( Counts const& other ); - std::size_t total() const; + std::uint64_t total() const; bool allPassed() const; bool allOk() const; - std::size_t passed = 0; - std::size_t failed = 0; - std::size_t failedButOk = 0; + std::uint64_t passed = 0; + std::uint64_t failed = 0; + std::uint64_t failedButOk = 0; }; struct Totals { diff --git a/src/catch2/internal/catch_string_manip.hpp b/src/catch2/internal/catch_string_manip.hpp index bdc7c266..8ef47e39 100644 --- a/src/catch2/internal/catch_string_manip.hpp +++ b/src/catch2/internal/catch_string_manip.hpp @@ -44,14 +44,14 @@ namespace Catch { * **Important:** The provided string must outlive the instance */ struct pluralise { - pluralise(std::size_t count, StringRef label): + pluralise(std::uint64_t count, StringRef label): m_count(count), m_label(label) {} friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); - std::size_t m_count; + std::uint64_t m_count; StringRef m_label; }; } diff --git a/src/catch2/reporters/catch_reporter_compact.cpp b/src/catch2/reporters/catch_reporter_compact.cpp index 7a92d895..6c77003f 100644 --- a/src/catch2/reporters/catch_reporter_compact.cpp +++ b/src/catch2/reporters/catch_reporter_compact.cpp @@ -21,7 +21,7 @@ namespace { // Colour::LightGrey constexpr Catch::Colour::Code dimColour() { return Catch::Colour::FileName; } - constexpr Catch::StringRef bothOrAll( std::size_t count ) { + constexpr Catch::StringRef bothOrAll( std::uint64_t count ) { switch (count) { case 1: return Catch::StringRef{}; diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index 6e9ea34b..2b208f1c 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -178,12 +178,12 @@ private: bool printInfoMessages; }; -std::size_t makeRatio(std::size_t number, std::size_t total) { - std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; - return (ratio == 0 && number > 0) ? 1 : ratio; +std::size_t makeRatio( std::uint64_t number, std::uint64_t total ) { + const auto ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; + return (ratio == 0 && number > 0) ? 1 : static_cast<std::size_t>(ratio); } -std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) { +std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { if (i > j && i > k) return i; else if (j > k) @@ -597,7 +597,7 @@ struct SummaryColumn { SummaryColumn( std::string _label, Colour::Code _colour ) : label( CATCH_MOVE( _label ) ), colour( _colour ) {} - SummaryColumn addRow( std::size_t count ) { + SummaryColumn addRow( std::uint64_t count ) { ReusableStringStream rss; rss << count; std::string row = rss.str(); |