mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Counts internally use uint64_t instead of size_t
This ensures that even for 32 bit platforms, the assertion count should not plausibly overflow.
This commit is contained in:
parent
c49faa62dd
commit
dcf9479c85
@ -24,7 +24,7 @@ namespace Catch {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Counts::total() const {
|
std::uint64_t Counts::total() const {
|
||||||
return passed + failed + failedButOk;
|
return passed + failed + failedButOk;
|
||||||
}
|
}
|
||||||
bool Counts::allPassed() const {
|
bool Counts::allPassed() const {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define CATCH_TOTALS_HPP_INCLUDED
|
#define CATCH_TOTALS_HPP_INCLUDED
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@ -16,13 +17,13 @@ namespace Catch {
|
|||||||
Counts operator - ( Counts const& other ) const;
|
Counts operator - ( Counts const& other ) const;
|
||||||
Counts& operator += ( Counts const& other );
|
Counts& operator += ( Counts const& other );
|
||||||
|
|
||||||
std::size_t total() const;
|
std::uint64_t total() const;
|
||||||
bool allPassed() const;
|
bool allPassed() const;
|
||||||
bool allOk() const;
|
bool allOk() const;
|
||||||
|
|
||||||
std::size_t passed = 0;
|
std::uint64_t passed = 0;
|
||||||
std::size_t failed = 0;
|
std::uint64_t failed = 0;
|
||||||
std::size_t failedButOk = 0;
|
std::uint64_t failedButOk = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Totals {
|
struct Totals {
|
||||||
|
@ -44,14 +44,14 @@ namespace Catch {
|
|||||||
* **Important:** The provided string must outlive the instance
|
* **Important:** The provided string must outlive the instance
|
||||||
*/
|
*/
|
||||||
struct pluralise {
|
struct pluralise {
|
||||||
pluralise(std::size_t count, StringRef label):
|
pluralise(std::uint64_t count, StringRef label):
|
||||||
m_count(count),
|
m_count(count),
|
||||||
m_label(label)
|
m_label(label)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
|
friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
|
||||||
|
|
||||||
std::size_t m_count;
|
std::uint64_t m_count;
|
||||||
StringRef m_label;
|
StringRef m_label;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace {
|
|||||||
// Colour::LightGrey
|
// Colour::LightGrey
|
||||||
constexpr Catch::Colour::Code dimColour() { return Catch::Colour::FileName; }
|
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) {
|
switch (count) {
|
||||||
case 1:
|
case 1:
|
||||||
return Catch::StringRef{};
|
return Catch::StringRef{};
|
||||||
|
@ -178,12 +178,12 @@ private:
|
|||||||
bool printInfoMessages;
|
bool printInfoMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::size_t makeRatio(std::size_t number, std::size_t total) {
|
std::size_t makeRatio( std::uint64_t number, std::uint64_t total ) {
|
||||||
std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0;
|
const auto ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0;
|
||||||
return (ratio == 0 && number > 0) ? 1 : ratio;
|
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)
|
if (i > j && i > k)
|
||||||
return i;
|
return i;
|
||||||
else if (j > k)
|
else if (j > k)
|
||||||
@ -597,7 +597,7 @@ struct SummaryColumn {
|
|||||||
SummaryColumn( std::string _label, Colour::Code _colour )
|
SummaryColumn( std::string _label, Colour::Code _colour )
|
||||||
: label( CATCH_MOVE( _label ) ),
|
: label( CATCH_MOVE( _label ) ),
|
||||||
colour( _colour ) {}
|
colour( _colour ) {}
|
||||||
SummaryColumn addRow( std::size_t count ) {
|
SummaryColumn addRow( std::uint64_t count ) {
|
||||||
ReusableStringStream rss;
|
ReusableStringStream rss;
|
||||||
rss << count;
|
rss << count;
|
||||||
std::string row = rss.str();
|
std::string row = rss.str();
|
||||||
|
Loading…
Reference in New Issue
Block a user