diff options
author | Sven Gothel <[email protected]> | 2020-12-21 11:12:05 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-12-21 11:12:05 +0100 |
commit | a65ef73681248d14a7ec3727f349f758388d07c6 (patch) | |
tree | 3634abefe3f35dc6c5d4eb90311d2aa14a8c38e5 /include/jau/test | |
parent | 4f1583d727cfcafa087a9e98aad99ae56e481fa1 (diff) |
Replace cppunit.h with Catch2 (v3-devel): Supporting CI integration, more versatile functionality (benchmarking, ..)
Diffstat (limited to 'include/jau/test')
-rw-r--r-- | include/jau/test/catch2_ext.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/include/jau/test/catch2_ext.hpp b/include/jau/test/catch2_ext.hpp new file mode 100644 index 0000000..03a5d15 --- /dev/null +++ b/include/jau/test/catch2_ext.hpp @@ -0,0 +1,40 @@ +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +// Using Catch v3+ +// ---------------------------------------------------------- + +#ifndef CATCH2_EXT_H +#define CATCH2_EXT_H + +#include <catch2/catch_amalgamated.hpp> + +// namespace Catch { +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST_M( msg, macroName, resultDisposition, ... ) \ + do { \ + /* The expression should not be evaluated, but warnings should hopefully be checked */ \ + CATCH_INTERNAL_IGNORE_BUT_WARN(__VA_ARGS__); \ + std::string s1( macroName##_catch_sr ); \ + s1.append(msg); \ + s1.append(": "); \ + Catch::AssertionHandler catchAssertionHandler( s1, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) ) + + #define REQUIRE_MSG(MSG, ... ) INTERNAL_CATCH_TEST_M( MSG, "REQUIRE: ", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + #define INFO_STR( msg ) INTERNAL_CATCH_INFO( "INFO", static_cast<std::string>(msg) ) +// } + +#endif // CATCH2_EXT_H + |