1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/*
* Trompeloeil C++ mocking framework
*
* Copyright Björn Fahller 2014-2019
* Copyright Tore Martin Hagen 2019
*
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* Project home: https://github.com/rollbear/trompeloeil
*/
#ifndef TROMPELOEIL_CATCH2_HPP_
#define TROMPELOEIL_CATCH2_HPP_
#if !((defined(CATCH_CONFIG_PREFIX_ALL) && defined(CATCH_CHECK)) \
|| (!defined(CATCH_CONFIG_PREFIX_ALL) && defined(CHECK)))
#error "Catch2 macros must be defined before including <catch2/trompeloeil.hpp>"
#endif
#include "../trompeloeil.hpp"
namespace trompeloeil
{
template <>
inline void reporter<specialized>::send(
severity s,
const char* file,
unsigned long line,
const char* msg)
{
std::ostringstream os;
if (line) os << file << ':' << line << '\n';
os << msg;
auto failure = os.str();
if (s == severity::fatal)
{
#ifdef CATCH_CONFIG_PREFIX_ALL
CATCH_FAIL(failure);
#else
FAIL(failure);
#endif
}
else
{
#ifdef CATCH_CONFIG_PREFIX_ALL
CATCH_CAPTURE(failure);
CATCH_CHECK(failure.empty());
#else
CAPTURE(failure);
CHECK(failure.empty());
#endif
}
}
template <>
inline void reporter<specialized>::sendOk(
const char* trompeloeil_mock_calls_done_correctly)
{
#ifdef CATCH_CONFIG_PREFIX_ALL
CATCH_REQUIRE(trompeloeil_mock_calls_done_correctly != 0);
#else
REQUIRE(trompeloeil_mock_calls_done_correctly != 0);
#endif
}
}
#endif //TROMPELOEIL_CATCH2_HPP_
|