mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Moved inline functions in cpp files into anon namespaces
This commit is contained in:
parent
504607701b
commit
b8553d62a3
@ -18,10 +18,12 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
inline auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {
|
namespace {
|
||||||
|
auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {
|
||||||
expr.streamReconstructedExpression( os );
|
expr.streamReconstructedExpression( os );
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LazyExpression::LazyExpression( bool isNegated )
|
LazyExpression::LazyExpression( bool isNegated )
|
||||||
: m_isNegated( isNegated )
|
: m_isNegated( isNegated )
|
||||||
|
@ -14,6 +14,12 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
char toLowerCh(char c) {
|
||||||
|
return static_cast<char>( std::tolower( c ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool startsWith( std::string const& s, std::string const& prefix ) {
|
bool startsWith( std::string const& s, std::string const& prefix ) {
|
||||||
return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
|
return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());
|
||||||
}
|
}
|
||||||
@ -29,9 +35,6 @@ namespace Catch {
|
|||||||
bool contains( std::string const& s, std::string const& infix ) {
|
bool contains( std::string const& s, std::string const& infix ) {
|
||||||
return s.find( infix ) != std::string::npos;
|
return s.find( infix ) != std::string::npos;
|
||||||
}
|
}
|
||||||
inline char toLowerCh(char c) {
|
|
||||||
return static_cast<char>( std::tolower( c ) );
|
|
||||||
}
|
|
||||||
void toLowerInPlace( std::string& s ) {
|
void toLowerInPlace( std::string& s ) {
|
||||||
std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
|
std::transform( s.begin(), s.end(), s.begin(), toLowerCh );
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
|
namespace {
|
||||||
|
TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {
|
||||||
if( startsWith( tag, '.' ) ||
|
if( startsWith( tag, '.' ) ||
|
||||||
tag == "!hide" )
|
tag == "!hide" )
|
||||||
return TestCaseInfo::IsHidden;
|
return TestCaseInfo::IsHidden;
|
||||||
@ -36,15 +37,16 @@ namespace Catch {
|
|||||||
else
|
else
|
||||||
return TestCaseInfo::None;
|
return TestCaseInfo::None;
|
||||||
}
|
}
|
||||||
inline bool isReservedTag( std::string const& tag ) {
|
bool isReservedTag( std::string const& tag ) {
|
||||||
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast<unsigned char>(tag[0]) );
|
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast<unsigned char>(tag[0]) );
|
||||||
}
|
}
|
||||||
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
|
void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
|
||||||
CATCH_ENFORCE( !isReservedTag(tag),
|
CATCH_ENFORCE( !isReservedTag(tag),
|
||||||
"Tag name: [" << tag << "] is not allowed.\n"
|
"Tag name: [" << tag << "] is not allowed.\n"
|
||||||
<< "Tag names starting with non alpha-numeric characters are reserved\n"
|
<< "Tag names starting with non alpha-numeric characters are reserved\n"
|
||||||
<< _lineInfo );
|
<< _lineInfo );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TestCase makeTestCase( ITestInvoker* _testCase,
|
TestCase makeTestCase( ITestInvoker* _testCase,
|
||||||
std::string const& _className,
|
std::string const& _className,
|
||||||
|
@ -18,7 +18,8 @@ namespace Catch {
|
|||||||
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto estimateClockResolution() -> uint64_t {
|
namespace {
|
||||||
|
auto estimateClockResolution() -> uint64_t {
|
||||||
uint64_t sum = 0;
|
uint64_t sum = 0;
|
||||||
static const uint64_t iterations = 1000000;
|
static const uint64_t iterations = 1000000;
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ namespace Catch {
|
|||||||
// - and potentially do more iterations if there's a high variance.
|
// - and potentially do more iterations if there's a high variance.
|
||||||
return sum/iterations;
|
return sum/iterations;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
auto getEstimatedClockResolution() -> uint64_t {
|
auto getEstimatedClockResolution() -> uint64_t {
|
||||||
static auto s_resolution = estimateClockResolution();
|
static auto s_resolution = estimateClockResolution();
|
||||||
return s_resolution;
|
return s_resolution;
|
||||||
|
Loading…
Reference in New Issue
Block a user