mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Tidied up result enums
This commit is contained in:
parent
7717c29072
commit
4ea535e505
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
// ResultWas::OfType enum
|
||||||
struct ResultWas { enum OfType {
|
struct ResultWas { enum OfType {
|
||||||
Unknown = -1,
|
Unknown = -1,
|
||||||
Ok = 0,
|
Ok = 0,
|
||||||
@ -32,6 +33,7 @@ namespace Catch {
|
|||||||
return ( resultType & ResultWas::FailureBit ) == 0;
|
return ( resultType & ResultWas::FailureBit ) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResultAction::Value enum
|
||||||
struct ResultAction { enum Value {
|
struct ResultAction { enum Value {
|
||||||
None,
|
None,
|
||||||
Failed = 1, // Failure - but no debug break if Debug bit not set
|
Failed = 1, // Failure - but no debug break if Debug bit not set
|
||||||
@ -39,26 +41,22 @@ namespace Catch {
|
|||||||
Abort = 4 // Test run should abort
|
Abort = 4 // Test run should abort
|
||||||
}; };
|
}; };
|
||||||
|
|
||||||
struct ResultDisposition {
|
// ResultDisposition::Flags enum
|
||||||
enum Flags {
|
struct ResultDisposition { enum Flags {
|
||||||
Normal = 0x00,
|
Normal = 0x00,
|
||||||
|
|
||||||
ContinueOnFailure = 0x01,
|
ContinueOnFailure = 0x01, // Failures fail test, but execution continues
|
||||||
NegateResult = 0x02,
|
NegateResult = 0x02, // Prefix expressiom with !
|
||||||
SuppressFail = 0x04
|
SuppressFail = 0x04 // Failures are reported but do not fail the test
|
||||||
};
|
}; };
|
||||||
};
|
|
||||||
inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
|
inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
|
||||||
return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
|
return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool testFlag( int flags, int bitOrBitsToTest ) { return ( flags & bitOrBitsToTest ) == bitOrBitsToTest; }
|
inline bool shouldContinueOnFailure( int flags ) { return flags & ResultDisposition::ContinueOnFailure; }
|
||||||
inline bool setFlag( int flags, int bitOrBitsToSet ) { return static_cast<ResultDisposition::Flags>( flags | bitOrBitsToSet ); }
|
inline bool shouldNegate( int flags ) { return flags & ResultDisposition::NegateResult; }
|
||||||
inline bool resetFlag( int flags, int bitOrBitsToReset ) { return static_cast<ResultDisposition::Flags>( flags & ~bitOrBitsToReset ); }
|
inline bool shouldSuppressFailure( int flags ) { return flags & ResultDisposition::SuppressFail; }
|
||||||
|
|
||||||
inline bool shouldContinueOnFailure( int flags ) { return testFlag( flags, ResultDisposition::ContinueOnFailure ); }
|
|
||||||
inline bool shouldNegate( int flags ) { return testFlag( flags, ResultDisposition::NegateResult ); }
|
|
||||||
inline bool shouldSuppressFailure( int flags ) { return testFlag( flags, ResultDisposition::SuppressFail ); }
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user