trompeloeil

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

trompeloeil.hpp (1265B)


      1 /*
      2  * Trompeloeil C++ mocking framework
      3  *
      4  * Copyright Björn Fahller 2014-2019
      5  * Copyright (C) 2019 Andrew Paxie
      6  *
      7  *  Use, modification and distribution is subject to the
      8  *  Boost Software License, Version 1.0. (See accompanying
      9  *  file LICENSE_1_0.txt or copy at
     10  *  http://www.boost.org/LICENSE_1_0.txt)
     11  *
     12  * Project home: https://github.com/rollbear/trompeloeil
     13  */
     14 
     15 
     16 #ifndef TROMPELOEIL_CXXTEST_HPP_
     17 #define TROMPELOEIL_CXXTEST_HPP_
     18 
     19 #ifndef CXXTEST_FLAGS
     20 #error "<cxxtest/TestSuite.h> must be included before <cxxtest/trompeloeil.hpp>"
     21 #endif
     22 
     23 #include "../trompeloeil.hpp"
     24 
     25 #include <ostream>
     26 #include <sstream>
     27 
     28 namespace trompeloeil
     29 {
     30   template <>
     31   inline void reporter<specialized>::send(
     32     severity s,
     33     const char* file,
     34     unsigned long line,
     35     const char* msg)
     36   {
     37     std::ostringstream os;
     38     if (line) os << file << ':' << line << '\n';
     39     os << msg;
     40     auto failure = os.str();
     41     if (s == severity::fatal)
     42     {
     43       // Must not return normally i.e. must throw, abort or terminate.
     44       TS_FAIL(failure);
     45     }
     46     else
     47     {
     48       // nonfatal: violation occurred during stack rollback.
     49       // Must not throw an exception.
     50       TS_WARN(failure);
     51     }
     52   }
     53 } /* namespace trompeloeil */
     54 
     55 #endif //TROMPELOEIL_CXXTEST_HPP_