From a65ef73681248d14a7ec3727f349f758388d07c6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 21 Dec 2020 11:12:05 +0100 Subject: Replace cppunit.h with Catch2 (v3-devel): Supporting CI integration, more versatile functionality (benchmarking, ..) --- include/jau/test/catch2_ext.hpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/jau/test/catch2_ext.hpp (limited to 'include/jau/test') 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 + +// 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( !!(__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(msg) ) +// } + +#endif // CATCH2_EXT_H + -- cgit v1.2.3