mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-18 03:26:10 +01:00
performance improvement - isTrue, isFalseTest, SourceLineInfo ctor
inlined isTrue, isFalseTest and SourceLineInfo ctor. Further work on #1086. Brings test from 0m25.584s to 0m20.635s
This commit is contained in:
parent
f18366150e
commit
7732835f9a
@ -15,10 +15,6 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) noexcept
|
|
||||||
: file( _file ),
|
|
||||||
line( _line )
|
|
||||||
{}
|
|
||||||
bool SourceLineInfo::empty() const noexcept {
|
bool SourceLineInfo::empty() const noexcept {
|
||||||
return file[0] == '\0';
|
return file[0] == '\0';
|
||||||
}
|
}
|
||||||
@ -38,7 +34,6 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isTrue( bool value ){ return value; }
|
|
||||||
bool alwaysTrue() { return true; }
|
bool alwaysTrue() { return true; }
|
||||||
bool alwaysFalse() { return false; }
|
bool alwaysFalse() { return false; }
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ namespace Catch {
|
|||||||
struct SourceLineInfo {
|
struct SourceLineInfo {
|
||||||
|
|
||||||
SourceLineInfo() = delete;
|
SourceLineInfo() = delete;
|
||||||
SourceLineInfo( char const* _file, std::size_t _line ) noexcept;
|
SourceLineInfo( char const* _file, std::size_t _line ) noexcept
|
||||||
|
: file( _file ), line( _line ) {}
|
||||||
|
|
||||||
SourceLineInfo( SourceLineInfo const& other ) = default;
|
SourceLineInfo( SourceLineInfo const& other ) = default;
|
||||||
SourceLineInfo( SourceLineInfo && ) = default;
|
SourceLineInfo( SourceLineInfo && ) = default;
|
||||||
@ -61,7 +62,7 @@ namespace Catch {
|
|||||||
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
|
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
|
||||||
|
|
||||||
// This is just here to avoid compiler warnings with macro constants and boolean literals
|
// This is just here to avoid compiler warnings with macro constants and boolean literals
|
||||||
bool isTrue( bool value );
|
inline bool isTrue( bool value ) { return value; }
|
||||||
bool alwaysTrue();
|
bool alwaysTrue();
|
||||||
bool alwaysFalse();
|
bool alwaysFalse();
|
||||||
|
|
||||||
@ -82,4 +83,3 @@ namespace Catch {
|
|||||||
::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
|
::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
|
bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
|
||||||
bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
|
|
||||||
bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
|
bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@ -47,7 +47,7 @@ namespace Catch {
|
|||||||
ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs );
|
ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs );
|
||||||
|
|
||||||
bool shouldContinueOnFailure( int flags );
|
bool shouldContinueOnFailure( int flags );
|
||||||
bool isFalseTest( int flags );
|
inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
|
||||||
bool shouldSuppressFailure( int flags );
|
bool shouldSuppressFailure( int flags );
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user