Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
catch2_ext.hpp
Go to the documentation of this file.
1 /*
2  * Author: Sven Gothel <sgothel@jausoft.com>
3  * Copyright (c) 2020 Gothel Software e.K.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  *************************************************************************
25  *
26  * Distributed under the Boost Software License, Version 1.0.
27  * (See accompanying file LICENSE_1_0.txt or copy at
28  * https://www.boost.org/LICENSE_1_0.txt)
29  *
30  * SPDX-License-Identifier: BSL-1.0
31  */
32 
33 #ifndef CATCH2_EXT_H
34 #define CATCH2_EXT_H
35 
36 #include <catch2/catch_amalgamated.hpp>
37 #include <jau/float_math.hpp>
38 
39 // namespace Catch {
40 ///////////////////////////////////////////////////////////////////////////////
41 #define INTERNAL_CATCH_TEST_M( msg, macroName, resultDisposition, ... ) \
42  do { \
43  /* The expression should not be evaluated, but warnings should hopefully be checked */ \
44  CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \
45  std::string s1( macroName##_catch_sr ); \
46  s1.append(msg); \
47  s1.append(": "); \
48  Catch::AssertionHandler catchAssertionHandler( s1, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \
49  INTERNAL_CATCH_TRY { \
50  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
51  CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
52  catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \
53  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
54  } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
55  INTERNAL_CATCH_REACT( catchAssertionHandler ) \
56  } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) )
57 
58  #define REQUIRE_MSG(MSG, ... ) INTERNAL_CATCH_TEST_M( MSG, "REQUIRE: ", Catch::ResultDisposition::Normal, __VA_ARGS__ )
59  #define INFO_STR( msg ) INTERNAL_CATCH_INFO( "INFO", static_cast<std::string>(msg) )
60 
61  #define REQUIRE_EPSI(a,b) INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::machine_equal(a, b))
62  #define REQUIRE_EPSI_MSG(m,a,b) INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::machine_equal(a, b))
63 
64  #define REQUIRE_DIFF(a,b,d) INTERNAL_CATCH_TEST( "REQUIRE: ", Catch::ResultDisposition::Normal, jau::machine_equal(a, b, 1, d))
65  #define REQUIRE_DIFF_MSG(m,a,b,d) INTERNAL_CATCH_TEST_M( m, "REQUIRE: ", Catch::ResultDisposition::Normal, jau::machine_equal(a, b, 1, d))
66 
67 // }
68 
69 #if !defined(CATCH_CONFIG_MAIN)
71 #endif /* !defined(CATCH_CONFIG_MAIN) */
72 
73 #endif // CATCH2_EXT_H
74 
float_math.hpp
catch2_my_main.cpp