1 /* 2 * Created by Phil on 07/01/2011. 3 * Copyright 2011 Two Blue Cubes Ltd. All rights reserved. 4 * 5 * Distributed under the Boost Software License, Version 1.0. (See accompanying 6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 */ 8 #ifndef TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED 9 #define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED 10 11 namespace Catch { 12 13 // ResultWas::OfType enum 14 struct ResultWas { enum OfType { 15 Unknown = -1, 16 Ok = 0, 17 Info = 1, 18 Warning = 2, 19 20 FailureBit = 0x10, 21 22 ExpressionFailed = FailureBit | 1, 23 ExplicitFailure = FailureBit | 2, 24 25 Exception = 0x100 | FailureBit, 26 27 ThrewException = Exception | 1, 28 DidntThrowException = Exception | 2, 29 30 FatalErrorCondition = 0x200 | FailureBit 31 32 }; }; 33 isOk(ResultWas::OfType resultType)34 inline bool isOk( ResultWas::OfType resultType ) { 35 return ( resultType & ResultWas::FailureBit ) == 0; 36 } isJustInfo(int flags)37 inline bool isJustInfo( int flags ) { 38 return flags == ResultWas::Info; 39 } 40 41 42 // ResultDisposition::Flags enum 43 struct ResultDisposition { enum Flags { 44 Normal = 0x01, 45 46 ContinueOnFailure = 0x02, // Failures fail test, but execution continues 47 FalseTest = 0x04, // Prefix expression with ! 48 SuppressFail = 0x08 // Failures are reported but do not fail the test 49 }; }; 50 51 inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { 52 return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) ); 53 } 54 shouldContinueOnFailure(int flags)55 inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } isFalseTest(int flags)56 inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } shouldSuppressFailure(int flags)57 inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } 58 59 } // end namespace Catch 60 61 #endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED 62