Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9676b82

Browse files
committedMar 2, 2024·
Update Catch2 version 3.5.3
1 parent 0e59234 commit 9676b82

File tree

3 files changed

+216
-90
lines changed

3 files changed

+216
-90
lines changed
 

‎Include/catch/catch_amalgamated.cpp

+53-34
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
// SPDX-License-Identifier: BSL-1.0
77

8-
// Catch v3.5.2
9-
// Generated: 2024-01-15 14:06:36.675713
8+
// Catch v3.5.3
9+
// Generated: 2024-03-01 22:05:56.038084
1010
// ----------------------------------------------------------
1111
// This file is an amalgamation of multiple different files.
1212
// You probably shouldn't edit it directly.
@@ -72,8 +72,8 @@ namespace Catch {
7272
FDuration mean = FDuration(0);
7373
int i = 0;
7474
for(auto it = first; it < last; ++it, ++i) {
75-
samples.push_back(FDuration(*it));
76-
mean += FDuration(*it);
75+
samples.push_back(*it);
76+
mean += *it;
7777
}
7878
mean /= i;
7979

@@ -432,7 +432,7 @@ namespace {
432432

433433
namespace Catch {
434434
Approx::Approx(double value)
435-
: m_epsilon(std::numeric_limits<float>::epsilon() * 100.)
435+
: m_epsilon(static_cast<double>(std::numeric_limits<float>::epsilon()) * 100.)
436436
, m_margin(0.0)
437437
, m_scale(0.0)
438438
, m_value(value) {}
@@ -810,6 +810,7 @@ namespace Catch {
810810
m_messages.back().message += " := ";
811811
start = pos;
812812
}
813+
default: ; // noop
813814
}
814815
}
815816
assert(openings.empty() && "Mismatched openings");
@@ -1196,8 +1197,10 @@ namespace Catch {
11961197
StringRef extractFilenamePart(StringRef filename) {
11971198
size_t lastDot = filename.size();
11981199
while(lastDot > 0 && filename[lastDot - 1] != '.') { --lastDot; }
1199-
--lastDot;
1200+
// In theory we could have filename without any extension in it
1201+
if(lastDot == 0) { return StringRef(); }
12001202

1203+
--lastDot;
12011204
size_t nameStart = lastDot;
12021205
while(nameStart > 0 && filename[nameStart - 1] != '/' && filename[nameStart - 1] != '\\') { --nameStart; }
12031206

@@ -1473,13 +1476,13 @@ namespace Catch {
14731476
}
14741477
} // end unnamed namespace
14751478

1476-
std::string convertIntoString(StringRef string, bool escape_invisibles) {
1479+
std::string convertIntoString(StringRef string, bool escapeInvisibles) {
14771480
std::string ret;
14781481
// This is enough for the "don't escape invisibles" case, and a good
14791482
// lower bound on the "escape invisibles" case.
14801483
ret.reserve(string.size() + 2);
14811484

1482-
if(!escape_invisibles) {
1485+
if(!escapeInvisibles) {
14831486
ret += '"';
14841487
ret += string;
14851488
ret += '"';
@@ -1547,6 +1550,7 @@ namespace Catch {
15471550
}
15481551

15491552
std::string StringMaker<char*>::convert(char* str) {
1553+
// NOLINT(readability-non-const-parameter)
15501554
if(str) { return Detail::convertIntoString(str); }
15511555
else { return {"{null string}"}; }
15521556
}
@@ -1617,7 +1621,7 @@ namespace Catch {
16171621

16181622
std::string StringMaker<char>::convert(char c) { return ::Catch::Detail::stringify(static_cast<signed char>(c)); }
16191623

1620-
std::string StringMaker<unsigned char>::convert(unsigned char c) { return ::Catch::Detail::stringify(static_cast<char>(c)); }
1624+
std::string StringMaker<unsigned char>::convert(unsigned char value) { return ::Catch::Detail::stringify(static_cast<char>(value)); }
16211625

16221626
int StringMaker<float>::precision = 5;
16231627

@@ -1699,7 +1703,7 @@ namespace Catch {
16991703
}
17001704

17011705
Version const& libraryVersion() {
1702-
static Version version(3, 5, 2, "", 0);
1706+
static Version version(3, 5, 3, "", 0);
17031707
return version;
17041708
}
17051709
}
@@ -2253,7 +2257,7 @@ namespace Catch {
22532257
while(std::getline(f, line)) {
22542258
line = trim(line);
22552259
if(!line.empty() && !startsWith(line, '#')) {
2256-
if(!startsWith(line, '"')) line = '"' + line + '"';
2260+
if(!startsWith(line, '"')) line = '"' + CATCH_MOVE(line) + '"';
22572261
config.testsOrTags.push_back(line);
22582262
config.testsOrTags.emplace_back(",");
22592263
}
@@ -2572,22 +2576,22 @@ namespace Catch {
25722576
} // end namespace Catch
25732577

25742578
namespace Catch {
2575-
Detail::unique_ptr<ColourImpl> makeColourImpl(ColourMode implSelection, IStream* stream) {
2579+
Detail::unique_ptr<ColourImpl> makeColourImpl(ColourMode colourSelection, IStream* stream) {
25762580
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
2577-
if(implSelection == ColourMode::Win32) { return Detail::make_unique<Win32ColourImpl>(stream); }
2581+
if(colourSelection == ColourMode::Win32) { return Detail::make_unique<Win32ColourImpl>(stream); }
25782582
#endif
2579-
if(implSelection == ColourMode::ANSI) { return Detail::make_unique<ANSIColourImpl>(stream); }
2580-
if(implSelection == ColourMode::None) { return Detail::make_unique<NoColourImpl>(stream); }
2583+
if(colourSelection == ColourMode::ANSI) { return Detail::make_unique<ANSIColourImpl>(stream); }
2584+
if(colourSelection == ColourMode::None) { return Detail::make_unique<NoColourImpl>(stream); }
25812585

2582-
if(implSelection == ColourMode::PlatformDefault) {
2586+
if(colourSelection == ColourMode::PlatformDefault) {
25832587
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
25842588
if(Win32ColourImpl::useImplementationForStream(*stream)) { return Detail::make_unique<Win32ColourImpl>(stream); }
25852589
#endif
25862590
if(ANSIColourImpl::useImplementationForStream(*stream)) { return Detail::make_unique<ANSIColourImpl>(stream); }
25872591
return Detail::make_unique<NoColourImpl>(stream);
25882592
}
25892593

2590-
CATCH_ERROR("Could not create colour impl for selection " << static_cast<int>(implSelection));
2594+
CATCH_ERROR("Could not create colour impl for selection " << static_cast<int>(colourSelection));
25912595
}
25922596

25932597
bool isColourImplAvailable(ColourMode colourSelection) {
@@ -2772,7 +2776,11 @@ namespace Catch {
27722776
#endif // Platform
27732777

27742778
namespace Catch {
2775-
ITransientExpression::~ITransientExpression() = default;
2779+
void ITransientExpression::streamReconstructedExpression(std::ostream& os) const {
2780+
// We can't make this function pure virtual to keep ITransientExpression
2781+
// constexpr, so we write error message instead
2782+
os << "Some class derived from ITransientExpression without overriding streamReconstructedExpression";
2783+
}
27762784

27772785
void formatReconstructedExpression(std::ostream& os, std::string const& lhs, StringRef op, std::string const& rhs) {
27782786
if(lhs.size() + rhs.size() < 40 && lhs.find('\n') == std::string::npos && rhs.find('\n') == std::string::npos) os << lhs << ' ' << op << ' ' << rhs;
@@ -3311,7 +3319,7 @@ namespace Catch {
33113319
: m_os{os}
33123320
, m_indent_level{indent_level} { m_os << '{'; }
33133321

3314-
JsonObjectWriter::JsonObjectWriter(JsonObjectWriter&& source)
3322+
JsonObjectWriter::JsonObjectWriter(JsonObjectWriter&& source) noexcept
33153323
: m_os{source.m_os}
33163324
, m_indent_level{source.m_indent_level}
33173325
, m_should_comma{source.m_should_comma}
@@ -3339,7 +3347,7 @@ namespace Catch {
33393347
: m_os{os}
33403348
, m_indent_level{indent_level} { m_os << '['; }
33413349

3342-
JsonArrayWriter::JsonArrayWriter(JsonArrayWriter&& source)
3350+
JsonArrayWriter::JsonArrayWriter(JsonArrayWriter&& source) noexcept
33433351
: m_os{source.m_os}
33443352
, m_indent_level{source.m_indent_level}
33453353
, m_should_comma{source.m_should_comma}
@@ -3923,7 +3931,10 @@ namespace Catch {
39233931
auto kv = splitKVPair(parts[i]);
39243932
auto key = kv.key, value = kv.value;
39253933

3926-
if(key.empty() || value.empty()) { return {}; }
3934+
if(key.empty() || value.empty()) {
3935+
// NOLINT(bugprone-branch-clone)
3936+
return {};
3937+
}
39273938
else if(key[0] == 'X') {
39283939
// This is a reporter-specific option, we don't check these
39293940
// apart from basic sanity checks
@@ -4703,15 +4714,24 @@ namespace Catch {
47034714
}
47044715

47054716
bool replaceInPlace(std::string& str, std::string const& replaceThis, std::string const& withThis) {
4706-
bool replaced = false;
47074717
std::size_t i = str.find(replaceThis);
4708-
while(i != std::string::npos) {
4709-
replaced = true;
4710-
str = str.substr(0, i) + withThis + str.substr(i + replaceThis.size());
4711-
if(i < str.size() - withThis.size()) i = str.find(replaceThis, i + withThis.size());
4718+
if(i == std::string::npos) { return false; }
4719+
std::size_t copyBegin = 0;
4720+
std::string origStr = CATCH_MOVE(str);
4721+
str.clear();
4722+
// There is at least one replacement, so reserve with the best guess
4723+
// we can make without actually counting the number of occurences.
4724+
str.reserve(origStr.size() - replaceThis.size() + withThis.size());
4725+
do {
4726+
str.append(origStr, copyBegin, i - copyBegin);
4727+
str += withThis;
4728+
copyBegin = i + replaceThis.size();
4729+
if(copyBegin < origStr.size()) i = origStr.find(replaceThis, copyBegin);
47124730
else i = std::string::npos;
47134731
}
4714-
return replaced;
4732+
while(i != std::string::npos);
4733+
if(copyBegin < origStr.size()) { str.append(origStr, copyBegin, origStr.size()); }
4734+
return true;
47154735
}
47164736

47174737
std::vector<StringRef> splitStringRef(StringRef str, char delimiter) {
@@ -6875,8 +6895,8 @@ namespace Catch {
68756895
StreamingReporterBase::testRunEnded(_testRunStats);
68766896
}
68776897

6878-
void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) {
6879-
StreamingReporterBase::testRunStarting(_testInfo);
6898+
void ConsoleReporter::testRunStarting(TestRunInfo const& _testRunInfo) {
6899+
StreamingReporterBase::testRunStarting(_testRunInfo);
68806900
if(m_config->testSpec().hasFilters()) { m_stream << m_colour->guardColour(Colour::BrightYellow) << "Filters: " << m_config->testSpec() << '\n'; }
68816901
m_stream << "Randomness seeded to: " << getSeed() << '\n';
68826902
}
@@ -6993,8 +7013,7 @@ namespace Catch {
69937013
BySectionInfo(SectionInfo const& other)
69947014
: m_other(other) {}
69957015

6996-
BySectionInfo(BySectionInfo const& other)
6997-
: m_other(other.m_other) {}
7016+
BySectionInfo(BySectionInfo const& other) = default;
69987017

69997018
bool operator()(Detail::unique_ptr<CumulativeReporterBase::SectionNode> const& node) const { return ((node->stats.sectionInfo.name == m_other.name) && (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); }
70007019

@@ -7455,8 +7474,8 @@ namespace Catch {
74557474

74567475
std::string JsonReporter::getDescription() { return "Outputs listings as JSON. Test listing is Work-in-Progress!"; }
74577476

7458-
void JsonReporter::testRunStarting(TestRunInfo const& testInfo) {
7459-
StreamingReporterBase::testRunStarting(testInfo);
7477+
void JsonReporter::testRunStarting(TestRunInfo const& runInfo) {
7478+
StreamingReporterBase::testRunStarting(runInfo);
74607479
endListing();
74617480

74627481
assert(isInside( Writer::Object ));
@@ -7715,7 +7734,7 @@ namespace Catch {
77157734

77167735
static void normalizeNamespaceMarkers(std::string& str) {
77177736
std::size_t pos = str.find("::");
7718-
while(pos != str.npos) {
7737+
while(pos != std::string::npos) {
77197738
str.replace(pos, 2, ".");
77207739
pos += 1;
77217740
pos = str.find("::", pos);

0 commit comments

Comments
 (0)
Please sign in to comment.