mirror of
https://github.com/catchorg/Catch2.git
synced 2026-07-21 13:53:35 +00:00
Cleanups from static analysis
This commit is contained in:
@@ -32,6 +32,7 @@ Checks: >-
|
||||
-modernize-deprecated-headers,
|
||||
,# There's a lot of these and most of them are probably not useful,
|
||||
-modernize-pass-by-value,
|
||||
-modernize-use-string-view, # We support C++14,
|
||||
|
||||
performance-*,
|
||||
performance-enum-size,
|
||||
@@ -58,6 +59,8 @@ Checks: >-
|
||||
-readability-uppercase-literal-suffix,
|
||||
-readability-use-anyofallof,
|
||||
-readability-avoid-return-with-void-value,
|
||||
,# We prefer if defined(FOO) form because it is easier to extend later,
|
||||
-readability-use-concise-preprocessor-directives,
|
||||
|
||||
,# time hogs,
|
||||
-bugprone-throw-keyword-missing,
|
||||
|
||||
@@ -36,10 +36,10 @@ namespace Catch {
|
||||
samples.data(), samples.data() + samples.size() );
|
||||
|
||||
auto wrap_estimate = [](Estimate<double> e) {
|
||||
return Estimate<FDuration> {
|
||||
FDuration(e.point),
|
||||
FDuration(e.lower_bound),
|
||||
FDuration(e.upper_bound),
|
||||
return Estimate<FDuration>{
|
||||
FDuration( e.point ),
|
||||
FDuration( e.lower_bound ),
|
||||
FDuration( e.upper_bound ),
|
||||
e.confidence_interval,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -461,14 +461,13 @@ namespace Catch {
|
||||
Detail::g_lastAssertionPassed = true;
|
||||
} else if (!result.succeeded()) {
|
||||
Detail::g_lastAssertionPassed = false;
|
||||
if (result.isOk()) {
|
||||
}
|
||||
else if( m_activeTestCase->getTestCaseInfo().okToFail() ) // Read from a shared state established before the threads could start, this is fine
|
||||
if (result.isOk()) {}
|
||||
else if( m_activeTestCase->getTestCaseInfo().okToFail() ) { // Read from a shared state established before the threads could start, this is fine
|
||||
m_atomicAssertionCount.failedButOk++;
|
||||
else
|
||||
} else {
|
||||
m_atomicAssertionCount.failed++;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Detail::g_lastAssertionPassed = true;
|
||||
}
|
||||
|
||||
@@ -650,7 +649,7 @@ namespace Catch {
|
||||
// and since IResultCapture::getLastResult is deprecated,
|
||||
// we will leave it as is, until it is finally removed.
|
||||
Detail::LockGuard _( m_assertionMutex );
|
||||
return &(*m_lastResult);
|
||||
return &*m_lastResult;
|
||||
}
|
||||
|
||||
void RunContext::exceptionEarlyReported() {
|
||||
@@ -902,7 +901,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void RunContext::populateReaction( AssertionReaction& reaction,
|
||||
bool has_normal_disposition ) {
|
||||
bool has_normal_disposition ) const {
|
||||
reaction.shouldDebugBreak = m_shouldDebugBreak;
|
||||
reaction.shouldThrow = aborting() || has_normal_disposition;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Catch {
|
||||
ITransientExpression const *expr,
|
||||
bool negated );
|
||||
|
||||
void populateReaction( AssertionReaction& reaction, bool has_normal_disposition );
|
||||
void populateReaction( AssertionReaction& reaction, bool has_normal_disposition ) const;
|
||||
|
||||
// Creates dummy info for unexpected exceptions/fatal errors,
|
||||
// where we do not have the access to one, but we still need
|
||||
|
||||
@@ -16,11 +16,12 @@ namespace Catch {
|
||||
|
||||
TagAlias const* TagAliasRegistry::find( std::string const& alias ) const {
|
||||
auto it = m_registry.find( alias );
|
||||
if( it != m_registry.end() )
|
||||
return &(it->second);
|
||||
else
|
||||
if ( it != m_registry.end() ) {
|
||||
return &it->second;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
|
||||
std::string expandedTestSpec = unexpandedTestSpec;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Catch {
|
||||
|
||||
void throw_test_failure_exception() {
|
||||
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
|
||||
throw TestFailureException{};
|
||||
throw TestFailureException{}; //NOLINT(bugprone-std-exception-baseclass)
|
||||
#else
|
||||
CATCH_ERROR( "Test failure requires aborting test!" );
|
||||
#endif
|
||||
@@ -22,7 +22,7 @@ namespace Catch {
|
||||
|
||||
void throw_test_skip_exception() {
|
||||
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
|
||||
throw Catch::TestSkipException();
|
||||
throw Catch::TestSkipException(); //NOLINT(bugprone-std-exception-baseclass)
|
||||
#else
|
||||
CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" );
|
||||
#endif
|
||||
|
||||
@@ -124,7 +124,7 @@ struct AutoReg : Detail::NonCopyable {
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
struct DummyUse {
|
||||
DummyUse( void ( * )( int ), Catch::NameAndTags const& );
|
||||
DummyUse( void ( * )( int ), Catch::NameAndTags const& ) noexcept;
|
||||
};
|
||||
} // namespace Detail
|
||||
} // namespace Catch
|
||||
|
||||
@@ -20,9 +20,8 @@ namespace Catch {
|
||||
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 ) );
|
||||
return node->stats.sectionInfo.name == m_other.name
|
||||
&& node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
||||
}
|
||||
void operator=( BySectionInfo const& ) = delete;
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace {
|
||||
// -------------------------
|
||||
// | a | b | c | d |
|
||||
|
||||
#define CarryBits( x ) ( x >> 32 )
|
||||
#define Digits( x ) ( x & 0xFF'FF'FF'FF )
|
||||
#define CarryBits( x ) ( (x) >> 32 )
|
||||
#define Digits( x ) ( (x) & 0xFF'FF'FF'FF )
|
||||
|
||||
auto r2l2 = Digits( rhs ) * Digits( lhs );
|
||||
auto r2l1 = Digits( rhs ) * CarryBits( lhs );
|
||||
|
||||
@@ -27,8 +27,8 @@ TEST_CASE( "std::vector<std::pair<std::string,int> > -> toString", "[toString][p
|
||||
|
||||
// This is pretty contrived - I figure if this works, anything will...
|
||||
TEST_CASE( "pair<pair<int,const char *,pair<std::string,int> > -> toString", "[toString][pair]" ) {
|
||||
typedef std::pair<int,const char *> left_t;
|
||||
typedef std::pair<std::string,int> right_t;
|
||||
using left_t = std::pair<int,const char *>;
|
||||
using right_t = std::pair<std::string,int>;
|
||||
|
||||
left_t left( 42, "Arthur" );
|
||||
right_t right( "Ford", 24 );
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
TEST_CASE( "tuple<>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<> type;
|
||||
using type = std::tuple<>;
|
||||
CHECK( "{ }" == ::Catch::Detail::stringify(type{}) );
|
||||
type value {};
|
||||
CHECK( "{ }" == ::Catch::Detail::stringify(value) );
|
||||
@@ -21,33 +21,33 @@ TEST_CASE( "tuple<>", "[toString][tuple]" )
|
||||
|
||||
TEST_CASE( "tuple<int>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<int> type;
|
||||
using type = std::tuple<int>;
|
||||
CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) );
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE( "tuple<float,int>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<float,int> type;
|
||||
using type = std::tuple<float,int>;
|
||||
CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) );
|
||||
CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) );
|
||||
}
|
||||
|
||||
TEST_CASE( "tuple<string,string>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<std::string,std::string> type;
|
||||
using type = std::tuple<std::string,std::string>;
|
||||
CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) );
|
||||
}
|
||||
|
||||
TEST_CASE( "tuple<tuple<int>,tuple<>,float>", "[toString][tuple]" )
|
||||
{
|
||||
typedef std::tuple<std::tuple<int>,std::tuple<>,float> type;
|
||||
using type = std::tuple<std::tuple<int>,std::tuple<>,float>;
|
||||
type value { std::tuple<int>{42}, {}, 1.5f };
|
||||
CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) );
|
||||
}
|
||||
|
||||
TEST_CASE( "tuple<nullptr,int,const char *>", "[approvals][toString][tuple]" ) {
|
||||
typedef std::tuple<std::nullptr_t,int,const char *> type;
|
||||
using type = std::tuple<std::nullptr_t,int,const char *>;
|
||||
type value { nullptr, 42, "Catch me" };
|
||||
CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user