trompeloeil

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

side_effect_on_forbidden_call.cpp (769B)


      1 /*
      2  * Trompeloeil C++ mocking framework
      3  *
      4  * Copyright Björn Fahller 2015,2017
      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 //SIDE_EFFECT for forbidden call does not make sense
     15 
     16 #include <trompeloeil.hpp>
     17 #include <iostream>
     18 
     19 struct MS
     20 {
     21   MAKE_MOCK0(f, int());
     22 };
     23 
     24 int main()
     25 {
     26   MS obj;
     27 
     28 #if (TROMPELOEIL_CPLUSPLUS == 201103L)
     29 
     30   FORBID_CALL_V(obj, f(),
     31     .SIDE_EFFECT(std::cout << 3));
     32 
     33 #else /* (TROMPELOEIL_CPLUSPLUS == 201103L) */
     34 
     35   FORBID_CALL(obj, f())
     36     .SIDE_EFFECT(std::cout << 3);
     37 
     38 #endif /* !(TROMPELOEIL_CPLUSPLUS == 201103L) */
     39 }