mimic++ v9.2.1
Loading...
Searching...
No Matches
BoostTest.hpp
Go to the documentation of this file.
1// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at
4// https://www.boost.org/LICENSE_1_0.txt)
5
6#ifndef MIMICPP_ADAPTERS_BOOST_TEST_HPP
7#define MIMICPP_ADAPTERS_BOOST_TEST_HPP
8
9#pragma once
10
11#if __has_include("mimic++/Reporting.hpp")
12 #include "mimic++/Reporting.hpp"
14#elif not defined(MIMICPP_VERSION)
15 #error "It appears that the test-adapter is not included in the mimic++ project or package." \
16 "If you plan to use it alongside the mimic++-amalgamated header, please ensure to include the adapter-header afterwards."
17#endif
18
19#if __has_include(<boost/test/unit_test.hpp>)
20 #include <boost/test/unit_test.hpp>
21#else
22 #error "Unable to find Boost.Test includes."
23#endif
24
25namespace mimicpp::reporting::detail::boost_test
26{
27 struct failure
28 {
29 };
30
31 [[noreturn]]
32 inline void send_fail(StringViewT const msg)
33 {
34 BOOST_TEST_FAIL(msg);
36 }
37
38 inline void send_success(StringViewT const msg)
39 {
40 BOOST_TEST_MESSAGE(msg);
41 }
42
43 inline void send_warning(StringViewT const msg)
44 {
45 BOOST_TEST_MESSAGE("warning: ") << msg.data();
46 }
47}
48
49namespace mimicpp::reporting
50{
51 // GCOVR_EXCL_START
52
62 &detail::boost_test::send_success,
63 &detail::boost_test::send_warning,
64 &detail::boost_test::send_fail>;
65
66 // GCOVR_EXCL_STOP
67}
68
69namespace mimicpp::reporting::detail::boost_test
70{
71 [[maybe_unused]]
72 inline ReporterInstaller<BoostTestReporterT> const installer{};
73}
74
75#endif
A reporter, which creates text messages and reports them via the provided callbacks.
Definition BasicReporter.hpp:40
BasicReporter< &detail::boost_test::send_success, &detail::boost_test::send_warning, &detail::boost_test::send_fail > BoostTestReporterT
Reporter for the integration into Boost.Test.
Definition BoostTest.hpp:61
Definition BasicReporter.hpp:27
void unreachable()
Invokes undefined behavior.
Definition C++23Backports.hpp:40
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Fwd.hpp:392