mimic++ v9.2.1
Loading...
Searching...
No Matches
Doctest.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_DOCTEST_HPP
7#define MIMICPP_ADAPTERS_DOCTEST_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(<doctest/doctest.h>)
20 #include <doctest/doctest.h>
21#else
22 #error "Unable to find Doctest includes."
23#endif
24
25namespace mimicpp::reporting::detail::doctest
26{
27 using namespace ::doctest;
28
29 [[noreturn]]
30 inline void send_fail(StringViewT const msg)
31 {
32 DOCTEST_FAIL(msg);
34 }
35
36 inline void send_success(StringViewT const msg)
37 {
38 DOCTEST_REQUIRE_MESSAGE(true, msg);
39 }
40
41 inline void send_warning(StringViewT const msg)
42 {
43 DOCTEST_MESSAGE(msg);
44 }
45}
46
47namespace mimicpp::reporting
48{
49 // GCOVR_EXCL_START
50
60 &detail::doctest::send_success,
61 &detail::doctest::send_warning,
62 &detail::doctest::send_fail>;
63
64 // GCOVR_EXCL_STOP
65}
66
67namespace mimicpp::reporting::detail::doctest
68{
69 [[maybe_unused]]
70 inline ReporterInstaller<DoctestReporterT> const installer{};
71}
72
73#endif
A reporter, which creates text messages and reports them via the provided callbacks.
Definition BasicReporter.hpp:40
BasicReporter< &detail::doctest::send_success, &detail::doctest::send_warning, &detail::doctest::send_fail > DoctestReporterT
Reporter for the integration into Doctest.
Definition Doctest.hpp:59
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