mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-08 15:19:54 +01:00
Cleanup some stuff found by MSVC's /analyze
* Added some missing `noexcept`s on custom destructors. * Fixed `std::move` being called on a const-reference. * Initialized `ScopedMessage::m_moved` in class definition, instead of doing so in constructors explicitly. * Turned some `enum`s into `enum class`es. * Initialized `StreamingReporterBase::currentTestCaseInfo` in class definition. * Some cleanups in SelfTest code.
This commit is contained in:
parent
2e480b6e56
commit
1a97af45f1
@ -81,14 +81,15 @@ namespace Catch {
|
||||
BenchmarkFunction(Fun&& fun)
|
||||
: f(new model<typename std::decay<Fun>::type>(std::forward<Fun>(fun))) {}
|
||||
|
||||
BenchmarkFunction(BenchmarkFunction&& that)
|
||||
: f(std::move(that.f)) {}
|
||||
BenchmarkFunction( BenchmarkFunction&& that ) noexcept:
|
||||
f( std::move( that.f ) ) {}
|
||||
|
||||
BenchmarkFunction(BenchmarkFunction const& that)
|
||||
: f(that.f->clone()) {}
|
||||
|
||||
BenchmarkFunction& operator=(BenchmarkFunction&& that) {
|
||||
f = std::move(that.f);
|
||||
BenchmarkFunction&
|
||||
operator=( BenchmarkFunction&& that ) noexcept {
|
||||
f = std::move( that.f );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -26,16 +26,14 @@ namespace Catch {
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
||||
: m_info( builder.m_info ), m_moved()
|
||||
{
|
||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder ):
|
||||
m_info( builder.m_info ) {
|
||||
m_info.message = builder.m_stream.str();
|
||||
getResultCapture().pushScopedMessage( m_info );
|
||||
}
|
||||
|
||||
ScopedMessage::ScopedMessage( ScopedMessage&& old )
|
||||
: m_info( old.m_info ), m_moved()
|
||||
{
|
||||
ScopedMessage::ScopedMessage( ScopedMessage&& old ) noexcept:
|
||||
m_info( std::move( old.m_info ) ) {
|
||||
old.m_moved = true;
|
||||
}
|
||||
|
||||
|
@ -49,11 +49,11 @@ namespace Catch {
|
||||
public:
|
||||
explicit ScopedMessage( MessageBuilder const& builder );
|
||||
ScopedMessage( ScopedMessage& duplicate ) = delete;
|
||||
ScopedMessage( ScopedMessage&& old );
|
||||
ScopedMessage( ScopedMessage&& old ) noexcept;
|
||||
~ScopedMessage();
|
||||
|
||||
MessageInfo m_info;
|
||||
bool m_moved;
|
||||
bool m_moved = false;
|
||||
};
|
||||
|
||||
class Capturer {
|
||||
|
@ -41,7 +41,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::vector<TagInfo> infos; infos.reserve(tagCounts.size());
|
||||
for (auto const& tagc : tagCounts) {
|
||||
for (auto& tagc : tagCounts) {
|
||||
infos.push_back(std::move(tagc.second));
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace Catch {
|
||||
|
||||
LazyStat<TestRunInfo> currentTestRunInfo;
|
||||
LazyStat<GroupInfo> currentGroupInfo;
|
||||
TestCaseInfo const* currentTestCaseInfo;
|
||||
TestCaseInfo const* currentTestCaseInfo = nullptr;
|
||||
|
||||
std::vector<SectionInfo> m_sectionStack;
|
||||
};
|
||||
|
@ -192,8 +192,9 @@ std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) {
|
||||
return k;
|
||||
}
|
||||
|
||||
enum class Justification { Left, Right };
|
||||
|
||||
struct ColumnInfo {
|
||||
enum Justification { Left, Right };
|
||||
std::string name;
|
||||
int width;
|
||||
Justification justification;
|
||||
@ -335,7 +336,7 @@ public:
|
||||
auto padding = (strSize + 1 < static_cast<std::size_t>(colInfo.width))
|
||||
? std::string(colInfo.width - (strSize + 1), ' ')
|
||||
: std::string();
|
||||
if (colInfo.justification == ColumnInfo::Left)
|
||||
if (colInfo.justification == Justification::Left)
|
||||
tp.m_os << colStr << padding << ' ';
|
||||
else
|
||||
tp.m_os << padding << colStr << ' ';
|
||||
@ -358,19 +359,19 @@ ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
|
||||
if (config.fullConfig()->benchmarkNoAnalysis())
|
||||
{
|
||||
return{
|
||||
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left },
|
||||
{ " samples", 14, ColumnInfo::Right },
|
||||
{ " iterations", 14, ColumnInfo::Right },
|
||||
{ " mean", 14, ColumnInfo::Right }
|
||||
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, Justification::Left },
|
||||
{ " samples", 14, Justification::Right },
|
||||
{ " iterations", 14, Justification::Right },
|
||||
{ " mean", 14, Justification::Right }
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return{
|
||||
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, ColumnInfo::Left },
|
||||
{ "samples mean std dev", 14, ColumnInfo::Right },
|
||||
{ "iterations low mean low std dev", 14, ColumnInfo::Right },
|
||||
{ "estimated high mean high std dev", 14, ColumnInfo::Right }
|
||||
{ "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 43, Justification::Left },
|
||||
{ "samples mean std dev", 14, Justification::Right },
|
||||
{ "iterations low mean low std dev", 14, Justification::Right },
|
||||
{ "estimated high mean high std dev", 14, Justification::Right }
|
||||
};
|
||||
}
|
||||
}())) {}
|
||||
|
@ -104,10 +104,10 @@ namespace {
|
||||
move_detector(move_detector const& rhs) = default;
|
||||
move_detector& operator=(move_detector const& rhs) = default;
|
||||
|
||||
move_detector(move_detector&& rhs) {
|
||||
move_detector(move_detector&& rhs) noexcept {
|
||||
rhs.has_moved = true;
|
||||
}
|
||||
move_detector& operator=(move_detector&& rhs) {
|
||||
move_detector& operator=(move_detector&& rhs) noexcept {
|
||||
rhs.has_moved = true;
|
||||
return *this;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ struct Obj
|
||||
{
|
||||
Obj():prop(&p){}
|
||||
|
||||
int p;
|
||||
int p = 0;
|
||||
int* prop;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user