Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:48:17

0001 
0002 //              Copyright Catch2 Authors
0003 // Distributed under the Boost Software License, Version 1.0.
0004 //   (See accompanying file LICENSE.txt or copy at
0005 //        https://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // SPDX-License-Identifier: BSL-1.0
0008 #ifndef CATCH_RESULT_TYPE_HPP_INCLUDED
0009 #define CATCH_RESULT_TYPE_HPP_INCLUDED
0010 
0011 namespace Catch {
0012 
0013     // ResultWas::OfType enum
0014     struct ResultWas { enum OfType {
0015         Unknown = -1,
0016         Ok = 0,
0017         Info = 1,
0018         Warning = 2,
0019         // TODO: Should explicit skip be considered "not OK" (cf. isOk)? I.e., should it have the failure bit?
0020         ExplicitSkip = 4,
0021 
0022         FailureBit = 0x10,
0023 
0024         ExpressionFailed = FailureBit | 1,
0025         ExplicitFailure = FailureBit | 2,
0026 
0027         Exception = 0x100 | FailureBit,
0028 
0029         ThrewException = Exception | 1,
0030         DidntThrowException = Exception | 2,
0031 
0032         FatalErrorCondition = 0x200 | FailureBit
0033 
0034     }; };
0035 
0036     constexpr bool isOk( ResultWas::OfType resultType ) {
0037         return ( resultType & ResultWas::FailureBit ) == 0;
0038     }
0039     constexpr bool isJustInfo( int flags ) { return flags == ResultWas::Info; }
0040 
0041 
0042     // ResultDisposition::Flags enum
0043     struct ResultDisposition { enum Flags {
0044         Normal = 0x01,
0045 
0046         ContinueOnFailure = 0x02,   // Failures fail test, but execution continues
0047         FalseTest = 0x04,           // Prefix expression with !
0048         SuppressFail = 0x08         // Failures are reported but do not fail the test
0049     }; };
0050 
0051     constexpr ResultDisposition::Flags operator|( ResultDisposition::Flags lhs,
0052                                         ResultDisposition::Flags rhs ) {
0053         return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) |
0054                                                       static_cast<int>( rhs ) );
0055     }
0056 
0057     constexpr bool isFalseTest( int flags ) {
0058         return ( flags & ResultDisposition::FalseTest ) != 0;
0059     }
0060     constexpr bool shouldSuppressFailure( int flags ) {
0061         return ( flags & ResultDisposition::SuppressFail ) != 0;
0062     }
0063 
0064 } // end namespace Catch
0065 
0066 #endif // CATCH_RESULT_TYPE_HPP_INCLUDED