mimic++ v4
Loading...
Searching...
No Matches
gtest.hpp
Go to the documentation of this file.
1// // Copyright Dominic (DNKpp) Koepke 2024 - 2024.
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_GTEST_HPP
7#define MIMICPP_ADAPTERS_GTEST_HPP
8
9#pragma once
10
11#include "mimic++/Reporter.hpp"
12
13#if __has_include(<gtest/gtest.h>)
14#include <gtest/gtest.h>
15#else
16 #error "Unable to find gtest includes."
17#endif
18
19namespace mimicpp::detail::gtest
20{
21 struct failure
22 {
23 };
24
25 [[noreturn]]
26 inline void send_fail(const StringViewT& msg)
27 {
28 // GTEST_FAIL has an immediate return
29 std::invoke(
30 [&]
31 {
32 GTEST_FAIL() << msg;
33 });
34
35 throw failure{};
36 }
37
38 inline void send_success(const StringViewT& msg)
39 {
40 GTEST_SUCCEED() << msg;
41 }
42
43 inline void send_warning([[maybe_unused]] const StringViewT& msg)
44 {
45 // seems unsupported
46 }
47}
48
49namespace mimicpp
50{
60 &detail::gtest::send_success,
61 &detail::gtest::send_warning,
62 &detail::gtest::send_fail
63 >;
64}
65
66namespace mimicpp::detail::gtest
67{
68 inline const ReporterInstaller<GTestReporterT> installer{};
69}
70
71#endif
A reporter, which creates text messages and reports them via the provided callbacks.
Definition Reporter.hpp:336
Definition BoostTest.hpp:20
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Fwd.hpp:208