mimic++ v5
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 GTEST_FAIL() << msg;
32 });
33
34 throw failure{};
35 }
36
37 inline void send_success(const StringViewT& msg)
38 {
39 GTEST_SUCCEED() << msg;
40 }
41
42 inline void send_warning([[maybe_unused]] const StringViewT& msg)
43 {
44 // seems unsupported
45 }
46}
47
48namespace mimicpp
49{
59 &detail::gtest::send_success,
60 &detail::gtest::send_warning,
61 &detail::gtest::send_fail>;
62}
63
64namespace mimicpp::detail::gtest
65{
66 inline const ReporterInstaller<GTestReporterT> installer{};
67}
68
69#endif
A reporter, which creates text messages and reports them via the provided callbacks.
Definition Reporter.hpp:328
Definition BoostTest.hpp:20
std::basic_string_view< CharT, CharTraitsT > StringViewT
Definition Fwd.hpp:343