trompeloeil

FORK: Header only C++14 mocking framework
git clone https://git.neptards.moe/u3shit/trompeloeil.git
Log | Files | Refs | README

trompeloeil.hpp (1300B)


      1 /*
      2  * Trompeloeil C++ mocking framework
      3  *
      4  * Copyright Björn Fahller 2014-2019
      5  *
      6  *  Use, modification and distribution is subject to the
      7  *  Boost Software License, Version 1.0. (See accompanying
      8  *  file LICENSE_1_0.txt or copy at
      9  *  http://www.boost.org/LICENSE_1_0.txt)
     10  *
     11  * Project home: https://github.com/rollbear/trompeloeil
     12  */
     13 
     14 
     15 #ifndef TROMPELOEIL_DOCTEST_HPP_
     16 #define TROMPELOEIL_DOCTEST_HPP_
     17 
     18 #ifndef DOCTEST_VERSION_MAJOR
     19 #error "<doctest.h> must be included before <doctest/trompeloeil.hpp>"
     20 #endif
     21 
     22 #include "../trompeloeil.hpp"
     23 
     24 namespace trompeloeil
     25 {
     26   template <>
     27   inline void reporter<specialized>::send(
     28     severity s,
     29     const char* file,
     30     unsigned long line,
     31     const char* msg)
     32   {
     33     auto f = line ? file : "[file/line unavailable]";
     34     if (s == severity::fatal)
     35     {
     36       DOCTEST_ADD_FAIL_AT(f, line, msg);
     37     }
     38     else
     39     {
     40       DOCTEST_ADD_FAIL_CHECK_AT(f, line, msg);
     41     }
     42   }
     43 
     44   template <>
     45   inline void reporter<specialized>::sendOk(
     46     const char* trompeloeil_mock_calls_done_correctly)
     47   {
     48 #ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING
     49     DOCTEST_REQUIRE_UNARY(trompeloeil_mock_calls_done_correctly);
     50 #else
     51     DOCTEST_REQUIRE_NE(doctest::String(trompeloeil_mock_calls_done_correctly), "");
     52 #endif
     53   }
     54 }
     55 
     56 
     57 #endif //TROMPELOEIL_DOCTEST_HPP_