Header only C++14 mocking framework

Related tags

Testing trompeloeil
Overview

Trompeloeil

trompeloeil logo

CI codecov

Get: Conan

trompe l'oeil noun (Concise Encyclopedia) Style of representation in which a painted object is intended to deceive the viewer into believing it is the object itself...

What is it?

A thread-safe header-only mocking framework for C++11/14 using the Boost Software License 1.0

Documentation

Also, follow up with the post on sequencing for examples on how to restrict or relax allowed sequences of matching calls.

Teaser

#include <trompeloeil.hpp>

class Interface
{
public:
  virtual ~Interface() = default;
  virtual bool foo(int, std::string& s) = 0;
  virtual bool bar(int) = 0;
  virtual bool bar(std::string) = 0;
};

void interface_func(Interface*); // function to test

class Mock : public Interface
{
public:
  MAKE_MOCK2(foo, bool(int, std::string&),override);
  MAKE_MOCK1(bar, bool(int),override);
  MAKE_MOCK1(bar, bool(std::string),override);
  MAKE_MOCK0(baz, void()); // not from Interface
};

TEST(exercise_interface_func)
{
  using trompeloeil::_;  // wild card for matching any value
  using trompeloeil::gt; // greater-than match

  Mock m;

  trompeloeil::sequence seq1, seq2;  // control order of matching calls

  int local_var = 0;

  REQUIRE_CALL(m, bar(ANY(int)))     // expect call to m.bar(int)
    .LR_SIDE_EFFECT(local_var = _1)  // set captured variable to value of param
    .RETURN(_1 > 0)                  // return value depending on param value
    .IN_SEQUENCE(seq1)               // must be first match for seq1
    .TIMES(AT_LEAST(1));             // can be called several times

  FORBID_CALL(m, bar(0));            // but m.bar(0) is not allowed

  REQUIRE_CALL(m, bar("word"))       // expect one call to m.bar(std::string)
    .RETURN(true)
    .IN_SEQUENCE(seq2);              // must be first match for seq2

  REQUIRE_CALL(m, foo(gt(2), _))     // expect call to foo(int,std::string&)
    .WITH(_2 == "")                  // with int > 2 and empty string
    .IN_SEQUENCE(seq1, seq2)         // last for both seq1 and seq2
    .SIDE_EFFECT(_2 = "cat")         // and set param string to "cat"
    .RETURN(true);

  interface_func(&m);

  // all the above expectations must be fulfilled here
}

How to contribute

Contributions are most welcome. For new functionality, please file an issue as an enhancement request first, to get a discussion going about how to best implement it. Also for bugfixes, it is good to file an issue, so that others can see what the problem is and when it's solved. Internal changes are normally not mentioned in the ChangeLog - it should typically reflect what a user can see (however, performance improvements and silencing warnings are visible for users.) Feel free to add your name to the copyright blurb.

Change PR to
Documentation master branch
Trivial bugfixes master branch
Non trivial bugfixes develop branch
Simple new functionality develop branch
Non-trivial new functionality new topic branch

Compiler compatibility

Trompeloeil is known to work with:

  • GCC 4.8.4+, 4.9.3+, 5, 6, 7, 8, 9, 10, 11
  • Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4, 5, 6, 7, 8, 9, 10, 11, 12
  • Visual Studio 2015, 2017, 2019

Latest patch level releases are assumed in the versions listed above.

Further details on C++11 support, platform and library limitations, may be found in

External Tools

Videos

Comments
  • Lower requirements to C++11?

    Lower requirements to C++11?

    Would it be much work to reduce the compiler requirements to C++11 instead? E.g., the Ubuntu 12.04 compilers does not (as far as I know) support C++14, which makes travis.org builds difficult.

    opened by SimonKagstrom 47
  • [fixed on master] `compiling_tests` fails with `clang++-6.0 -std=c++17`

    [fixed on master] `compiling_tests` fails with `clang++-6.0 -std=c++17`

    Summary

    clang++-6.0 on Ubuntu generates an error when compiling Trompeloeil in std=c++17 or std=c++2a modes.

    The latest version of Clang also generates this error.

    Environment

    Operating system: Ubuntu 18.04 LTS (Bionic Beaver)

    Compiler: clang++-6.0 and clang++ pre 7.0.0 a.k.a. clang++-latest.

    clang++-6.0 is from package clang-6.0 1:6.0-1ubuntu2.

    clang++-latest is locally built each day. This build current as at 26 June 2018.

    Flags: -std=c++17 or -std=c++2a.

    Command line

    clang++-6.0 \
    -std=c++17 \
    -Weverything \
    -Wno-c++98-compat-pedantic \
    -Wno-padded \
    -Wno-weak-vtables \
    -Wno-exit-time-destructors \
    -Wno-global-constructors \
    -I build/catch \
    -I ./include \
    -o compiling_tests \
    test/compiling_tests.cpp \
    test/compiling_tests_11.cpp \
    test/compiling_tests_14.cpp
    

    Expected behaviour

    Expected compiling_tests to build without error.

    Actual behaviour

    Compile error

    /usr/bin/../lib/gcc/x86_64-linux-gnu/8.0.1/../../../../include/c++/8.0.1/type_traits:945:14: error: base class has incomplete type
        : public is_constructible<_Tp, const _Tp&>
          ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    // ::: (some backtrace information omitted)
    
    test/compiling_tests.hpp:257:3: note: in instantiation of function template specialization 'trompeloeil::call_matcher<void (int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > &),
          std::tuple<trompeloeil::wildcard, trompeloeil::wildcard> >::call_matcher<const trompeloeil::wildcard &, const trompeloeil::wildcard &>' requested here
      MAKE_MOCK2(func, void(int, std::string&), override);
      ^
    
    // ::: (some more backtrace information omitted)
    
    test/compiling_tests_11.cpp:178:26: note: in instantiation of function template specialization 'mock_c::trompeloeil_l_tag_type_trompeloeil_257::func<const trompeloeil::wildcard &, const trompeloeil::wildcard &>' requested here
        REQUIRE_CALL_V(obj2, func(_, _),
                             ^
    

    Further information

    This error was encountered as I was gathering information to enable builds of Trompeloeil for C++17 and C++2a.

    These build configurations succeed (this is a subset of all the builds that succeed, with a focus on c++17 and c++2a):

                    Language    Standard
    Compiler        Standard    Library     Comment
    ----------      --------    --------    -------
    g++-5           c++17       stdc++      OK - no warnings, Pass
    g++-5           c++17       c++         OK - no warnings, Pass
    
    g++-6           c++17       stdc++      OK - no warnings, Pass
    g++-6           c++17       c++         OK - no warnings, Pass
    
    g++-7           c++17       stdc++      OK - no warnings, Pass
    g++-7           c++17       c++         OK - no warnings, Pass
    
    g++-8           c++17       stdc++      OK - no warnings, Pass
    g++-8           c++17       c++         OK - no warnings, Pass
    g++-8           c++2a       stdc++      OK - no warnings, Pass
    g++-8           c++2a       c++         OK - no warnings, Pass
    
    g++-latest      c++17       stdc++      OK - no warnings, Pass
    g++-latest      c++17       c++         OK - no warnings, Pass
    g++-latest      c++2a       stdc++      OK - no warnings, Pass
    g++-latest      c++2a       c++         OK - no warnings, Pass
    
    clang++-5.0     c++17       stdc++ v8   OK - no warnings, Pass
    clang++-5.0     c++17       c++         OK - no warnings, Pass
    clang++-5.0     c++2a       stdc++ v8   OK - no warnings, Pass
    clang++-5.0     c++2a       c++         OK - no warnings, Pass
    
    clang++-6.0     c++11       stdc++ v8   OK - no warnings, Pass
    clang++-6.0     c++11       c++         OK - no warnings, Pass
    clang++-6.0     c++14       stdc++ v8   OK - no warnings, Pass
    clang++-6.0     c++14       c++         OK - no warnings, Pass
    
    clang++-latest  c++11       stdc++ v8   OK - no warnings, Pass
    clang++-latest  c++11       c++         OK - no warnings, Pass
    clang++-latest  c++14       stdc++ v8   OK - no warnings, Pass
    clang++-latest  c++14       c++         OK - no warnings, Pass
    

    Note that clang++-6.0 and clang++-latest succeeded in c++11 and c++14 modes.

    Either something is wrong with clang++-6.0 in the c++17 and c++2a modes, or Clang has implemented a change from a proposal that has has had an affect on type deduction.

    A quick look at the Clang bugzilla does not immediately reveal a previously filed defect report describing this problem.

    It is the return of the user-defined conversion problems with wildcard, but I'm left a little concerned there is a limited chance of a workaround in the library code.

    I'm raising this issue here, now, before I reduce the test case to the minimum required to reproduce the issue. I will add a comment with the test case once I have it.

    Ideas or pointers on how to resolve this are welcomed.

    opened by AndrewPaxie 46
  • Warning in Visual Studio Release build when mocking return structs

    Warning in Visual Studio Release build when mocking return structs

    Hello, we currently try to mock OpenVR.

    This works fine in general however throws an unreachable code warning in Visual Studio 2017 in Release build (not Debug). Since we have a warning==error policy, this is a problem.

    The problem occusr if I add this line

    ALLOW_CALL(openvr_mock.GetSystem(), GetProjectionMatrix(_, _, _))
          .RETURN(vr::HmdMatrix44_t());
    

    or any other return type where the return type is:

    struct HmdMatrix44_t
    {
    	float m[4][4];
    };
    

    This seems to be related to the returning of structs, because this warning does not occur for any other of the mocked methods, retuning something else.

    The warning is:

    1>...\trompeloeil.hpp(2033): error C2220: warning treated as error - no 'object' file generated
    1>...\trompeloeil.hpp(2033): warning C4702: unreachable code
    

    Any ideas what could cause this, and how I could potentially circumvent it?

    Fixed on main 
    opened by JohnboyJovi 31
  • Wildcard match tuple

    Wildcard match tuple

    This solves the old issue #129. I feel very uncomfortable with this fix, because I don't understand why it solves the problem. It provably does so, across several tests, which is obviously good, but I really want to understand why. I have asked, and received no answers. The solution was found by chance, not through analysis.

    @AndrewPaxie ?

    opened by rollbear 29
  • Issue #1: Back port Trompeloeil to C++11.

    Issue #1: Back port Trompeloeil to C++11.

    Back ported Trompeloeil to C++11.  Changes by file and directory:
    * `.travis.yml`
      * Added job for `g++-4.8` C++11 mode.
      * Accepted 4 errors in `check_errors.sh` when in C++11 mode.
    * `CMakeLists.txt`
      * Allowed C++ dialect to be specified on command line using
        `CXX_STANDARD="11"` for C++11, default C++14.
      * Fixed Catch at version 1.11.0, given 2.0.1 triggers a defect
        in `g++` when compiling `libc++`.
      * Refined which sanitizers can be used based on given compiler
        and compiler version.
    * `README.md`
      * Updated supported compiler list.
      * Added link to `docs/Backward.md`.
      * Added link to `docs/PlatformAndLibraries.md`.
    * `include/trompeloeil.hpp`
      * Significantly reworked to accommodate the C++11 API and
        support compilation in a C++11 dialect.
    * `check_errors.sh`
      * Require `CXXFLAGS` with either `-std=c++11` or `-std=c++14`.
    * `docs/FAQ.md`
      * Updated supported compilers list.
      * Updated answer regarding C++11 support.
    * `docs/`
      * New: "Backward compatibility with earlier versions of C++".
      * New: "Platform and library support for Trompeloeil".
    * `compilation_errors/`
      * Support for C++11 expectation syntax in test cases.
    * `test/`
      * Split `compiling_tests.cpp` into separately compilable files,
        for Catch main, C++11 test cases and C++14 test cases.
    

    First round review.

    opened by AndrewPaxie 25
  • Issue with GCC 8.3 since v36

    Issue with GCC 8.3 since v36

    Hi,

    since v36 the following snippet does not compile with GCC 8.3 anymore (it still works with clang-9):

    #include <catch2/catch.hpp>
    #include <catch2/trompeloeil.hpp>
    
    #include <QObject>
    
    class Mock
    {
    public:
        MAKE_MOCK0(f, bool());
    };
    
    TEST_CASE("")
    {
        Mock m;
        REQUIRE_CALL(m, f()).RETURN(true);
    }
    
    /usr/local/include/trompeloeil.hpp: In instantiation of ‘constexpr bool trompeloeil::is_null(const T&) [with T = bool]’:
    /usr/local/include/trompeloeil.hpp:1274:16:   required from ‘void trompeloeil::print(std::ostream&, const T&) [with T = bool; std::ostream = std::basic_ostream<char>]’
    /usr/local/include/trompeloeil.hpp:2962:14:   required from ‘T trompeloeil::trace_agent::trace_return(T&&) [with T = bool]’
    /usr/local/include/trompeloeil.hpp:3104:45:   required from ‘Ret trompeloeil::trace_return(trompeloeil::trace_agent&, F&, P&) [with Ret = bool; F = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; P = std::tuple<>; <template-parameter-1-4> = void]’
    /usr/local/include/trompeloeil.hpp:3128:44:   required from ‘trompeloeil::return_of_t<Sig> trompeloeil::return_handler_t<Sig, T>::call(trompeloeil::trace_agent&, trompeloeil::call_params_type_t<Sig>&) [with Sig = bool(); T = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; trompeloeil::return_of_t<Sig> = bool; trompeloeil::call_params_type_t<Sig> = std::tuple<>]’
    /usr/local/include/trompeloeil.hpp:3123:5:   required from here
    /usr/local/include/trompeloeil.hpp:1145:34: error: no matching function for call to ‘is_null(const bool&, tag)’
         return ::trompeloeil::is_null(t, tag{});
                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
    /usr/local/include/trompeloeil.hpp:1111:3: note: candidate: ‘template<class T> constexpr decltype ((t == nullptr)) trompeloeil::is_null(const T&, std::true_type)’
       is_null(
       ^~~~~~~
    /usr/local/include/trompeloeil.hpp:1111:3: note:   template argument deduction/substitution failed:
    /usr/local/include/trompeloeil.hpp: In substitution of ‘template<class T> constexpr decltype ((t == nullptr)) trompeloeil::is_null(const T&, std::true_type) [with T = bool]’:
    /usr/local/include/trompeloeil.hpp:1145:34:   required from ‘constexpr bool trompeloeil::is_null(const T&) [with T = bool]’
    /usr/local/include/trompeloeil.hpp:1274:16:   required from ‘void trompeloeil::print(std::ostream&, const T&) [with T = bool; std::ostream = std::basic_ostream<char>]’
    /usr/local/include/trompeloeil.hpp:2962:14:   required from ‘T trompeloeil::trace_agent::trace_return(T&&) [with T = bool]’
    /usr/local/include/trompeloeil.hpp:3104:45:   required from ‘Ret trompeloeil::trace_return(trompeloeil::trace_agent&, F&, P&) [with Ret = bool; F = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; P = std::tuple<>; <template-parameter-1-4> = void]’
    /usr/local/include/trompeloeil.hpp:3128:44:   required from ‘trompeloeil::return_of_t<Sig> trompeloeil::return_handler_t<Sig, T>::call(trompeloeil::trace_agent&, trompeloeil::call_params_type_t<Sig>&) [with Sig = bool(); T = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; trompeloeil::return_of_t<Sig> = bool; trompeloeil::call_params_type_t<Sig> = std::tuple<>]’
    /usr/local/include/trompeloeil.hpp:3123:5:   required from here
    /usr/local/include/trompeloeil.hpp:1115:17: error: invalid operands of types ‘const bool’ and ‘std::nullptr_t’ to binary ‘operator==’
       -> decltype(t == nullptr)
                   ~~^~~~~~~~~~
    /usr/local/include/trompeloeil.hpp: In instantiation of ‘constexpr bool trompeloeil::is_null(const T&) [with T = bool]’:
    /usr/local/include/trompeloeil.hpp:1274:16:   required from ‘void trompeloeil::print(std::ostream&, const T&) [with T = bool; std::ostream = std::basic_ostream<char>]’
    /usr/local/include/trompeloeil.hpp:2962:14:   required from ‘T trompeloeil::trace_agent::trace_return(T&&) [with T = bool]’
    /usr/local/include/trompeloeil.hpp:3104:45:   required from ‘Ret trompeloeil::trace_return(trompeloeil::trace_agent&, F&, P&) [with Ret = bool; F = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; P = std::tuple<>; <template-parameter-1-4> = void]’
    /usr/local/include/trompeloeil.hpp:3128:44:   required from ‘trompeloeil::return_of_t<Sig> trompeloeil::return_handler_t<Sig, T>::call(trompeloeil::trace_agent&, trompeloeil::call_params_type_t<Sig>&) [with Sig = bool(); T = ____C_A_T_C_H____T_E_S_T____1()::<lambda(auto:1&)>; trompeloeil::return_of_t<Sig> = bool; trompeloeil::call_params_type_t<Sig> = std::tuple<>]’
    /usr/local/include/trompeloeil.hpp:3123:5:   required from here
    /usr/local/include/trompeloeil.hpp:1124:3: note: candidate: ‘template<class T> constexpr bool trompeloeil::is_null(const T&, std::false_type)’
       is_null(
       ^~~~~~~
    /usr/local/include/trompeloeil.hpp:1124:3: note:   template argument deduction/substitution failed:
    /usr/local/include/trompeloeil.hpp:1145:34: note:   cannot convert ‘tag{}’ (type ‘tag’ {aka ‘std::integral_constant<bool, true>’}) to type ‘std::false_type’ {aka ‘std::integral_constant<bool, false>’}
         return ::trompeloeil::is_null(t, tag{});
                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
    /usr/local/include/trompeloeil.hpp:1136:3: note: candidate: ‘template<class T> constexpr bool trompeloeil::is_null(const T&)’
       is_null(
       ^~~~~~~
    /usr/local/include/trompeloeil.hpp:1136:3: note:   template argument deduction/substitution failed:
    /usr/local/include/trompeloeil.hpp:1145:34: note:   candidate expects 1 argument, 2 provided
         return ::trompeloeil::is_null(t, tag{});
                ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
    
    bug Fixed on main 
    opened by weeebell 24
  • Segmentation fault / infinite loop in regular expression when handling fmt::is_formattable types

    Segmentation fault / infinite loop in regular expression when handling fmt::is_formattable types

    So this is weird, but in

    #include <fmt/format.h>
    #include <trompeloeil.hpp>
    #include <type_traits>
    
    #if 1
    namespace trompeloeil {
    
    template<typename T>
    struct printer<T, typename std::enable_if<fmt::is_formattable<T>::value>::type>
    {
        static void print(std::ostream& os, const T& t) noexcept { os << fmt::format("{}", t); }
    };
    
    }
    #endif
    
    class mock
    {
      public:
        MAKE_MOCK1(function_call, void(const std::string& text));
    };
    
    int main() {
    	mock test;
    	REQUIRE_CALL_V(test, function_call(trompeloeil::re("A")));
    #if 0
    	test.function_call("A");
    #else
    	test.function_call("B");
    #endif
    }
    

    I get an infinite loop (optimized build) or segmentation fault with a backtrace with a loooooong recursion of trompeloeil::duck_typed_matcher<trompeloeil::lambdas::regex_check, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::operator char const*&&<char const*, void, bool>() const ( this=0x4632b8) at trompeloeil/include/trompeloeil.hpp:1151 (debug build) as long as those #if are as they are. If you remove the printer, or make the regular expression match, the problem goes away.

    The problem happens with both gcc 11.2 and clang 13.

    Fixed on main 
    opened by reddwarf69 19
  • Exception thrown exit

    Exception thrown exit

    Using

    • trompeloeil v25
    • catch
    • Mac OS 10.12.6
    • apple-clang 8.1

    Tests crash with:

    libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: recursive_mutex lock failed: Invalid argument
    

    in trompeloeil.hpp line 3224:

    template <typename Sig>
      struct expectations
      {
        ~expectations() {
          active.decommission();
          saturated.decommission();
        }                                    # line 3224   
        call_matcher_list<Sig> active;
        call_matcher_list<Sig> saturated;
      };
    

    Have you seen this before?

    opened by tomvierjahn 19
  • clang 7.0.1 and TSAN warns about a data race in trompeloeil::get_lock

    clang 7.0.1 and TSAN warns about a data race in trompeloeil::get_lock

    Please see the minimal test case. It seems that with all of the following options are met:

    • using clang 6.0 or 7.0.1
    • using libc++ v6 or v7
    • TSAN (-fsanitize=thread) enabled
    • optimizing at least -O2

    ...then line 666 causes two separate mutexes to be created. This quite likely has something to do with multiple translation units.

    I cannot help but point out that it cannot be a mere coincidence that the offending line is line 666.

    Here's what the thread sanitizer reports. Note that these two threads each lock a "different" mutex even though the actual mutex should be the same as far as I can tell.

    ==================
    WARNING: ThreadSanitizer: data race (pid=4888)
      Write of size 8 at 0x7b0800000028 by thread T1 (mutexes: write M5):
        #0 trompeloeil::sequence_handler<1ul>::retire() <null> (doit+0x4b4871)
        #1 trompeloeil::call_matcher<void (), std::__1::tuple<> >::run_actions(std::__1::tuple<>&, trompeloeil::call_matcher_list<void ()>&) <null> (doit+0x4b31e3)
        #2 trompeloeil::return_of<void ()>::type trompeloeil::mock_func<false, void ()>(std::__1::integral_constant<bool, true>, trompeloeil::expectations<false, void ()>&, char const*, char const*) <null> (doit+0x4af37c)
        #3 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, main::$_0> >(void*) <null> (doit+0x4aed3d)
    
      Previous read of size 8 at 0x7b0800000028 by main thread (mutexes: write M9):
        #0 check(trompeloeil::sequence const&) <null> (doit+0x4b4f74)
        #1 main <null> (doit+0x4aeb63)
    
      Location is heap block of size 24 at 0x7b0800000020 allocated by main thread:
        #0 operator new(unsigned long) /var/tmp/portage/sys-libs/compiler-rt-sanitizers-6.0.0/work/compiler-rt-6.0.0.src/lib/tsan/rtl/tsan_new_delete.cc:57:3 (doit+0x4ad9f9)
        #1 main <null> (doit+0x4ae7bc)
    
      Mutex M5 (0x7b1000000018) created at:
        #0 pthread_mutex_init /var/tmp/portage/sys-libs/compiler-rt-sanitizers-6.0.0/work/compiler-rt-6.0.0.src/lib/tsan/rtl/tsan_interceptors.cc:1211:3 (doit+0x446143)
        #1 std::__1::__libcpp_recursive_mutex_init(pthread_mutex_t*) /var/tmp/portage/sys-libs/libcxx-7.0.1/work/libcxx-7.0.1.src/include/__threading_support:221:28 (libc++.so.1+0x82e6d)
        #2 std::__1::recursive_mutex::recursive_mutex() /var/tmp/portage/sys-libs/libcxx-7.0.1/work/libcxx-7.0.1.src/src/mutex.cpp:54:43 (libc++.so.1+0x82e6d)
        #3 _GLOBAL__sub_I_main.cpp <null> (doit+0x41daff)
        #4 __libc_csu_init /var/tmp/portage/sys-libs/glibc-2.25-r11/work/glibc-2.25/csu/elf-init.c:88:8 (doit+0x4b5274)
    
      Mutex M9 (0x7b1000000058) created at:
        #0 pthread_mutex_init /var/tmp/portage/sys-libs/compiler-rt-sanitizers-6.0.0/work/compiler-rt-6.0.0.src/lib/tsan/rtl/tsan_interceptors.cc:1211:3 (doit+0x446143)
        #1 std::__1::__libcpp_recursive_mutex_init(pthread_mutex_t*) /var/tmp/portage/sys-libs/libcxx-7.0.1/work/libcxx-7.0.1.src/include/__threading_support:221:28 (libc++.so.1+0x82e6d)
        #2 std::__1::recursive_mutex::recursive_mutex() /var/tmp/portage/sys-libs/libcxx-7.0.1/work/libcxx-7.0.1.src/src/mutex.cpp:54:43 (libc++.so.1+0x82e6d)
        #3 _GLOBAL__sub_I_check.cpp <null> (doit+0x41db9f)
        #4 __libc_csu_init /var/tmp/portage/sys-libs/glibc-2.25-r11/work/glibc-2.25/csu/elf-init.c:88:8 (doit+0x4b5274)
    
      Thread T1 (tid=4890, running) created by main thread at:
        #0 pthread_create /var/tmp/portage/sys-libs/compiler-rt-sanitizers-6.0.0/work/compiler-rt-6.0.0.src/lib/tsan/rtl/tsan_interceptors.cc:992:3 (doit+0x445035)
        #1 main <null> (doit+0x4aeb51)
    
    SUMMARY: ThreadSanitizer: data race (/home/jkt/temp/clang-tsan-static-mutex/doit+0x4b4871) in trompeloeil::sequence_handler<1ul>::retire()
    ==================
    ThreadSanitizer: reported 1 warnings
    

    I would appreciate some help in minimizing this example so that it does not actually use Trompeloeil so that it can be reported to LLVM upstream.

    bug Fixed on main 
    opened by jktjkt 18
  • [Fixed on master] Visual Studio 2015 Update 3

    [Fixed on master] Visual Studio 2015 Update 3

    I was trying an experiment with Catch and Trompeloeil with VS 2015 Update 3, but when including Trompeloeil, I get this:

    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2672: 'std::regex_search': no matching overloaded function found
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'const auto'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2965): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &&,std::match_results<basic_string<_Elem,_StTraits,_StAlloc>::const_iterator,_Alloc> &,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &&' from 'const auto'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2953): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,std::match_results<basic_string<_Elem,_StTraits,_StAlloc>::const_iterator,_Alloc> &,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'const auto'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2936): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(const _Elem *,std::match_results<const _Elem*,_Alloc> &,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for 'const _Elem *' from 'const auto'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2921): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(const _Elem *,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for 'const _Elem *' from 'const auto'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2907): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2782: 'bool std::regex_search(_BidIt,_BidIt,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': template parameter '_BidIt' is ambiguous
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2894): note: see declaration of 'std::regex_search'
    1>  c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): note: could be 'std::regex'
    1>  c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): note: or       'auto'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2784: 'bool std::regex_search(_BidIt,_BidIt,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': could not deduce template argument for '_BidIt' from 'std::regex'
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2894): note: see declaration of 'std::regex_search'
    1>c:\users\mlimber\desktop\test\catchtest\catchtest\trompeloeil.hpp(1402): error C2780: 'bool std::regex_search(_BidIt,_BidIt,std::match_results<_BidIt,_Alloc> &,const std::basic_regex<_Elem,_RxTraits> &,std::regex_constants::match_flag_type)': expects 5 arguments - 3 provided
    1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\regex(2881): note: see declaration of 'std::regex_search'
    

    Reducing my code to include ONLY trompeloeil, not include Catch or anything else, I still get these messages. I tried with the default settings and /std:c++14 just to be safe, but get the same result.

    opened by mlimber 18
  • fix c++11 msvc support

    fix c++11 msvc support

    Hi, I have some problems using the trompeloeil in the Visual Studio 2015, it does not support full С++14. Therefore, I think in Visual Studio 2015 need use С++ 11 API trompeloeil.

    Maybe it's worth adding test in Appveyor CI with Visual Studio 2015 and Visual Studio 2017.

    opened by Neargye 17
  • CMakeLists.txt has lower minimum required version to features used

    CMakeLists.txt has lower minimum required version to features used

    The cmake file only requires v3.2 cmake_minimum_required(VERSION 3.2) but has at least one feature only introduced in v3.14. ARCH_INDEPENDENT was added in v3.14 https://cmake.org/cmake/help/v3.14/release/3.14.html#modules

    This means building with cmake >=v3.2, <v3.14 fails:

    user:~/.apps/trompeloeil/build$ cmake -G "Unix Makefiles" ..
    -- The C compiler identification is GNU 7.5.0
    -- The CXX compiler identification is GNU 7.5.0
    -- Check for working C compiler: /usr/bin/cc
    -- Check for working C compiler: /usr/bin/cc -- works
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Check for working CXX compiler: /usr/bin/c++
    -- Check for working CXX compiler: /usr/bin/c++ -- works
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    CMake Error at /usr/share/cmake-3.10/Modules/WriteBasicConfigVersionFile.cmake:30 (message):
      Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE():
      "ARCH_INDEPENDENT"
    Call Stack (most recent call first):
      /usr/share/cmake-3.10/Modules/CMakePackageConfigHelpers.cmake:207 (write_basic_config_version_file)
      CMakeLists.txt:9 (write_basic_package_version_file)
    
    
    Fixed on main 
    opened by ljden 3
  • Non-constexpr TIMES

    Non-constexpr TIMES

    Hey

    Currently the TIMES macro requires that its argument must be constexpr. This makes it not possible to use in a parametrized test or helper function where the number of calls depends on some parameter.

    What is the reason behind this limitation, and can it be removed?

    Thanks

    opened by Swassie 4
  • Compile without exceptions

    Compile without exceptions

    I'm currently working in a environment where exceptions is disabled (No /EHxx flags in MSVC and _HAS_EXCEPTIONS=0). When I compile I get the warning: "C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc"

    Is it possible to compile a exceptions free version? Something like: DOCTEST_CONFIG_NO_EXCEPTIONS I couldn't find any options in the source?

    If not, would it be feasible to implement it, and would it be something of interest?

    opened by MarkusRannare 1
  • How to handle CI build coverage uploads?

    How to handle CI build coverage uploads?

    The state of things right now is that (line) coverage is collected with kcov for Linux builds only, and is forwarded to codecov.io.

    There are several problems here, however.

    • kcov is (not quite, but effectively) linux only, and it is incompatible with sanitizer builds, which requires a separate step. This project is not married to kcov, so we can use other solutions.
    • codecov.io has a limit on the number of coverage uploads it accepts for a single commit SHA-1. We're currently close enough to that limit that a release-push to main plus a tag for the same commit causes uploads to fail because the number of allowed uploads for one commit has been exceeded.
    • Regardless of why, the failure to upload coverage information is not a cause to fail a build, even though it is worthy of notice. Is there a middle ground between pass/fail? I have no problem with a release tag build failing an upload if it refers to a successful build of the same git commit, but i also want successful coverage information to PR builds so that I can easily judge if the PR should have more tests or not.
    • Can we improve this by collecting coverage information for non-linux builds?

    What options do we have to improve the above? Discus

    help wanted 
    opened by rollbear 0
Releases(v43)
  • v43(Oct 26, 2022)

    • Added static_assert to duck_typed_matcher's templatized conversion function explaining why it should never be instantiated. Issue #270.

    • Added gcc-12 and clang++-15 to the CI build matrix

    • Fixed issue #272: Support Catch2 piecemeal headers.

    • Fix issue #279 where the doctest adapter showed violation messages as hex addresses for most recent releases of doctest. Thanks @SimonKagstrom for reporting.

    • Fixed an obscure bug where an expectation could match with a sequence object that has run to completion.

    • Specify ARCH_INDEPENDENT when creating package version file in CMake.

    Source code(tar.gz)
    Source code(zip)
  • v42(Dec 7, 2021)

    • Fixed issue #264: Sequence objects did not correctly report is_complete() when there were living, but satisfied, expectations remaining. Thank you Václav Kubernát for reporting.

    • Fixed issue #259 where CMakeFiles.txt wrongly installed trompeloeil for projects that includes it. It is now an option. See FAQ for details. Thank you Ismail Pazarbasi for reporting and fixing.

    • Updated Catch2 to version 2.13.7 to compile unit tests on systems with glibc >= 2.34.

    • Fixed issue #255: Hex dumps showed byte values <= 15(dec) wrong. Thank you Stuart Dootson for reporting.

    • Fixed issue #253: Resolve lingering warnings in early Clang compilers and enable -Wzero-as-null-pointer-constant when compiling unit tests with GCC and Clang.

    • Fixed issue #250: Warnings about zero argument variadic macros with clang-msvc. Thank you u3shit for reporting and fixing.

    • Fixed issue #251: trompeloeil::printer<> customization point now supports SFINAE expressions to constrain partial specializations. Thank you Christian Morales Vega for reporting.

    • Fixed issue #245: Modify cmake to build thread_terror on Windows with MSVC.

    • Use CMake internal Threads::Threads target where needed. Thank you Martin Hořeňovský for reporting.

    • For CI builds, use github actions cacheing of built libc++ to shorten build times.

    • Added CMake install namespace. Thank you offa

    • Fixed bug where an expectation end of life was reported as an error if it was included in a satisfied sequence. Thank you Andy Saul.

    Source code(tar.gz)
    Source code(zip)
  • v41(Jun 15, 2021)

    • catch2 adapter works with CATCH_CONFIG_PREFIX_ALL. thanks Christian Morales Vega

    • Silenced -Wreserved-identifier from Clang "latest" (13.0.0).

    • Silenced (again) the MSVC C4702 warning from the default_return<>() function template.

    • Introduced type trompeloeil::printer as a customization point or formatting data to strings in reports. This has the advantage of allowing partial specializations. The old technique of specializing the function template trompeloeil::print(ostream&, const T&) still works.

    Source code(tar.gz)
    Source code(zip)
  • v40(Mar 14, 2021)

    • Silenced -Wnonnull warning from GCC 9 and newer. Thank you Tony Neubert.

    • Fixed custom reported documentation bug. Thanks Matt Godbolt.

    • Added CMake alias target trompeloeil::trompeloeil. Thank you Leon De Andrade.

    • Documentation markdown fixes. Thank you @offa.

    • Moved all CI builds to github actions. travis-ci and appveyor are no longer used.

    • Moved CI coverage collection to codecov.io

    • Conan recipe is now on https://conan.io/center/trompeloeil the old rollbear/stable channel is defunct. Thank you Florian Berchtold.

    Source code(tar.gz)
    Source code(zip)
  • v39(Oct 31, 2020)

    • Fix issue 204: ALLOW_CALL was not respected in sequences. Now ALLOW_CALL in sequence may be skipped, but making a call out of sequence is a violation. NOTE! This fix is likely to break some existing test code!

    • Fix issue 211: #include <QtCore/QChar> before #include <trompeloeil.hpp> caused compilation failure for all expectations.

    • Fix minor spelling errors and markdownlint warnings.

    • Issue 207: Extend cmake script to allow use of libc++ with g++

    • Fix issue 129: Wildcard _ does not match pass-by-value tuple of only one type.

    • Fix issue 197: Add override to virtual destructors to avoid -Wsuggest-destructor-override warnings.

    Source code(tar.gz)
    Source code(zip)
  • v38(Jun 8, 2020)

    • Fixed bug where ALLOW_CALL only worked with sequences if called at least once

    • Fixed bug to support IMPLEMENT_MOCKx and IMPLEMENT_CONST_MOCKx constexpr

    • More fixes to Conan packaging. Thank you Kai Bernhard.

    • Support OK-reporters from the runtime reporter registration API. Thank you Moritz Haase.

    • Rewrites to not trigger deprecation warnings in C++17 builds. Thank you Kasper Laudrup.

    Source code(tar.gz)
    Source code(zip)
  • 37(Feb 9, 2020)

    • Added adapter for the Criterion unit testing framework. Thank you

      Etienne Barbier [email protected]

    • Fixes to Conan packaging. Thank you kert

    • Fix issue 180 for GCC and MSVC, where the presence of a type like Qt5/QChar broke compilation of unrelated mock signatures.

    • Fix TROMPELOEIL_CONCAT macro issue to restore compiling with MSVC when traditional preprocessor is enabled.

    • Fix issue 173 for GCC 4.x by performing testing to confirm correctness of existing code.

    Source code(tar.gz)
    Source code(zip)
  • v36(Dec 29, 2019)

    • Status reporting of passed expectation calls as sucessful assertions in DOCTEST and Catch2. Thanks to:

      @ToreMartinHagen Catch2 @RedDwarf69 for DOCTEST

      You get the support via the provided headers

      #include <catch2/trompeloeil.hpp> #include <doctest/trompeloeil.hpp>

      See the CookBook for information about adding such hooks for other unit testing frame works.

    • Fixed issue #172 where THROW() would not compile if the function returns a type that is not default constructible.

    • Partially fixed issue #173, where an object constructible from nullptr but not comparable with nullptr, would be constructed when printed (for example when an expectation failed.)

      Unfortunately this fix does not work for gcc versions 4.x or MSVC 14.

    Source code(tar.gz)
    Source code(zip)
  • v35(Sep 24, 2019)

    • Improvements to documentation. Thanks to:

      Robert Dailey [email protected] Yuri Timenkov [email protected] Viatorus [email protected]

    • Improved DocTest integration. Thanks to:

      Cristian Morales Vega [email protected]

    • CMakeLists.txt honours CMAKE_INSTALL_LIBDIR. Thanks to:

      Cristian Morales Vega [email protected]

    • Partially fixed issue 155, where an unfulfilled expectation, when built with the default throwing reporter, terminated without a message when compiled with gcc and optimization. With the partial fix the program still terminates, but with the correct violation message displayed.

    • Fixed issue 157 where it was impossible to place an expectation on a reference to a non-copyable type. This fix also resolved a number of problems with older compilers. See docs/Backward.md for details.

    • Fixed clang-tidy warning, misc-non-private-member-variables-in-classes that leaks into application code from the Trompeloeil header.

    Source code(tar.gz)
    Source code(zip)
  • v34(Apr 1, 2019)

    • Rearranged include directory structure to make it easier to use, and to write, adapters for unit test frame works. Now, if you want to use Trompeloeil with, for example, the 'doctest' unit testing frame work, you include

      #include <doctest.h>
      #include <doctest/trompeloeil.hpp>
      

      The old adaptation mechanisms still work. See issue #118

    • Support compilation without RTTI support. This makes error reporting from deathwatched<> violations less informative (it cannot mention the name of the type of the object) but has no other impact on functionality.

    • Silenced g++-4.9 -Wmissing-field-initializers warning with libc++.

    • Fixed issue #121 where mutexes were created in each translation unit

    • Fixed issue #124 where sequence objects were not properly protected against access from several threads.

    • Silenced several warnings in the Trompeloeil self test programs.

    Source code(tar.gz)
    Source code(zip)
  • v33(Jan 21, 2019)

    • Silenced noisy g++-7 -Wuseless-cast warning

    • Fixed a bug where a mocked function would not compile if a parameter had an operator==(nullptr_t) returning a type that is not convertible to bool.

    • Fixed a bug where a mocked function would not compile if a parameter was a range with iterators to rvalue proxy objects, like vector<bool>.

    • Mock objects can be move constructed if they have a static constexpr bool member trompeloeil_movable_mock = true.

    • ANY() matcher gives a short descriptive compilation error message when the type is an array type (it would silently decay into a pointer type, which can be very confusing.)

    • When compiled with preprocessor macro TROMPELOEIL_USER_DEFINED_COMPILE_TIME_REPORTER, an extern trompeloeil::reporter is declared from trompeloeil.hpp. Thanks @rcdailey

    • Minor documentation updates.

    • Update pattern in expectation_with_wrong_type.cpp to match new error message from GCC '9' at svn revision 264700.

    Source code(tar.gz)
    Source code(zip)
  • v32(Jul 23, 2018)

    • Fix issue #95: check_errors.sh typo and detect failure in Travis

    • Update unit test framework to Catch 2.2.3.

    • Fix documentation of sanitize flags

    • Enable destructor override warning in self_test build for Clang 5.0 or later

    • Update unit test framework to Catch 2.2.1.

    • Worked around clang++-6 bugs 38010 and 38033

    • Improve support for compiler modes: GCC and Clang: -std=c++17; MSVC: /std:c++17 GCC and Clang: -std=c++2a; MSVC: /std:c++latest

    • Fix issue #87: C4355 warning from VS Release builds. Thanks @Neargye

    • Fix issue #69: work around C4702 warning from VS Release builds.

    • Fix issue #88: work around C2066 error from VS 2017 15.7.1.

    Source code(tar.gz)
    Source code(zip)
  • v31(May 11, 2018)

  • v30(Apr 2, 2018)

    • mock_interface<T> provides a convenient short cut when implementing mocks from interfaces. It is used together with the macros IMPLEMENT_MOCKn(func_name) and IMPLEMENT_CONST_MOCKn(func_name). The signature of the function is deduced. It is not possible to use mock_interface<T> with multiple inheritance, and it is not possible to mock overloads with IMPLEMENT_MOCKn(func_name) or IMPLEMENT_CONST_MOCKn(func_name)

    • Used markdownlint to make documentation more consistent. Thanks @AndrewPaxie

    • Silenced 2 clang++-5 warnings about missing "override"

    • Back ported Trompeloeil to C++11. Thanks @AndrewPaxie! Changes by file and directory:

      • Cleaned up .travis.yml
      • Cleaned up CMakeLists.txt and bumped kcov for travis builds
      • README.md
      • Updated supported compiler list.
      • Added link to docs/Backward.md.
      • Added link to docs/PlatformAndLibraries.md.
      • check_errors.sh require CXXFLAGS with either -std=c++11 or -std=c++14.
      • docs/FAQ.md
        • Updated supported compilers list.
        • Updated answer regarding C++11 support.
      • docs/
        • New: "Backward compatibility with earlier versions of C++".
        • New: "Platform and library support for Trompeloeil".
      • compilation_errors/
        • Support for C++11 expectation syntax in test cases.
      • test/
        • Split compiling_tests.cpp into separately compilable files, for Catch main, C++11 test cases and C++14 test cases.
    • Fixed whitespace and a minor spelling error in trompeloeil.hpp.

    • Tidy up test cases in compilation_errors.

    Source code(tar.gz)
    Source code(zip)
  • v29(Oct 23, 2017)

    • Fix Issue #54: Exception thrown exit - fixed static dtor fiasco
    • Fix Issue #48: Move "re" in lambda capture list in "regex_check".
    • Fix Issue #55: Restore warnings for Clang builds.
    • Fix Issue #57: Avoid uneeded-member-function warning from Clang.
    • Lightly edited documentation.
    Source code(tar.gz)
    Source code(zip)
  • v28(Jul 24, 2017)

    • You can place expectations on types multiply inheriting several mock types.

    • Changed directory structure. "trompeloeil.hpp" now resides in directory "include". Self test programs "compiling_tests.cpp" and "thread_terror.cpp" resides in directory "test".

    • Major work on CMake support

      • make install - works as before and also includes a package.
      • For CMake based project you can use
        • find_package(trompeloeil 28 REQUIRED) and add target_link_libraries(<test_program> trompeloeil) for your test target
        • use add_subdirectory(trompeloeil) if you prefer to track the trompeloeil git repository and also here add target_link_libraries(<test_program> trompeloeil) for your test target
          • cmake -DBUILD_TYPE=Debug <trompeloeil-dir> enables the test targets self_test and thread_terror
            • -DSANITIZE=true enables ASAN and UBSAN for self_test, and TSAN and UBSAN for thread_terror
    Source code(tar.gz)
    Source code(zip)
  • v27(Jun 27, 2017)

    • Fixed a regression where NAMED_REQUIRE_DESTRUCTION(obj) accidentally resulted in a std::unique_ptr<trompeloeil::expectation> instead of std::unique_ptr<trompeloeil::lifetime_monitor> as documented.

    • Added a rudimentary CMakeLists.txt file. Thanks @a4z.

    Source code(tar.gz)
    Source code(zip)
  • v26(Jun 12, 2017)

  • v25(Apr 17, 2017)

    • Changed the expectation macros such that you can now have a macro that expands into several REQUIRE_CALL() (and the likes)

    • Fixed macro expansion bugs causing name clashes.

    • Documented clang++ 4 compatibility

    • Sequence objects are now movable and can, for example, be returned from functions.

    Source code(tar.gz)
    Source code(zip)
  • v24(Mar 10, 2017)

  • v23(Jan 29, 2017)

    • Matchers can be negated using the logical not operator !.

      Example:

      struct Mock {
        MAKE_MOCK1(func, void(const std::string&));
      };
      
      TEST(...)
      {
        using trompeloeil::re; // match regular expressions
        Mock m;
        REQUIRE_CALL(m, func(!re("^foo")));
          // calls to func with strings not matching the regex /^foo/
        ...
      }
      
    • Made sequence and its dependencies moveable. (mlimber)

      This means it's now possible to use tha Almost Always Auto style for sequence objects:

        auto seq = trompeloeil::sequence{};
      
    • Internal refactoring for substantially reduced compilation time.

    Source code(tar.gz)
    Source code(zip)
  • v22(Dec 13, 2016)

    • Messages from violations of expectations now print collections member wise. This goes for std::pair<>, std::tuple<> and any data type for which a range based for loop is possible. This is done recursively for the contents of the collections.
    • Worked around gcc bug 78446
    • Cleaned up -Wshadow warnings from gcc
    Source code(tar.gz)
    Source code(zip)
  • v21(Nov 13, 2016)

    • Tracing now includes return values and exceptions thrown. For exception types inherited from std::exception, the what() string is printed.
    • Fixed a bug when a member function in a mocked class calls a mocked function. This is now explicitly allowed, even when an expectation recursively calls the same function as a side effect.
    • Worked around VisualStudio 2015 update 3 issue where trailing return type for lambdas is not respected in template deduction context. This caused compilation errors when using matchers in expectations to overloaded functions.
    • Worked around VisualStudio 2015 update 3 issue with evaluating regex_search() in trailing return type spec for auto deduced string type.
    Source code(tar.gz)
    Source code(zip)
  • v20(Oct 5, 2016)

  • v19(Oct 3, 2016)

    • Fixed obscure bug when placing an expectation using a value implicitly convertible to the target type, but not equal comparable with it.

      Example:

            struct S
            {
              S(const char* s_) : s(s_) {}
              bool operator(const char*) = delete;
              bool operator==(const S& rh) const
              {
                return s == rh.s;
              }
              std::string s;
            };
      
            struct mock {
              MAKE_MOCK1(func, void(S));
            };
      
            TEST(...)
            {
              mock m;
              REQUIRE_CALL(m, func("string"));
              // now compiles and compares the function call parameter value
              // with S("string")
            }
      
    • Improved compilation error messages for type-mismatch situations in .RETURN()

    Source code(tar.gz)
    Source code(zip)
  • v18(Aug 18, 2016)

    • Writing custom matchers is much simplified through the use of function template make_matcher<>(), which accepts lambdas for predicate and printing error message.

      The old technique of inheriting from trompeloeil::matcher or trompeloeil::typed_matcher<T> still works.

      See CookBook for details.

    • Further internal restructuring for yet reduced test program build time.

    Source code(tar.gz)
    Source code(zip)
  • v17(Jun 11, 2016)

    • Use template specialization when writing adapter code for unit testing frame works. The old technique is used by default.
    • Internal restructuring for shorter compilation times. Compilation time reductions of more than 10% have been measured.
    Source code(tar.gz)
    Source code(zip)
  • v16(May 16, 2016)

    • .IN_SEQUENCE(...) can now be used with REQUIRE_DESTRUCTION(...) and NAMED_REQUIRE_DESTRUCTION(...) to ensure objects are destroyed in the intended order. Example:

      auto p1 = new trompeloeil::deathwatched<mock1>;
      auto p2 = new trompeloeil::deathwatched<mock2>;
      
      trompeloeil::sequence s;
      REQUIRE_DESTRUCTION(*p1)
        .IN_SEQUENCE(s);
      REQUIRE_DESTRUCTION(*p2)
        .IN_SEQUENCE(s);
      call_destroyer(p1, p2); // both must be destroyed, p1 before p2.
      
    • class trompeloeil::lifetime_monitor now inherits from class trompeloeil::expectation, so using

      std::unique_ptr<expectation> p = NAMED_REQUIRE_DESTRUCTION(obj);
      

      instead of

      std::unique_ptr<lifetime_monitor> p = NAMED_REQUIRE_DESTRUCTION(obj);
      

      works equally well, reduces the cognitive load a bit, and seems to build slightly faster.

    Source code(tar.gz)
    Source code(zip)
  • v15(Apr 29, 2016)

  • v14(Apr 27, 2016)

    • Fixed bug when the destruction of a sequence object with still living expectations caused call to abort().

    • You can now add extra trailing specifiers to a mock function, such as the override context sensitive specifier, and/or the keyword noexcept (careful with the latter if your registered reporter can/does throw.)

      Example:

      struct D : public B {
        MAKE_MOCK1(func, int(int), override);
      };
      
    Source code(tar.gz)
    Source code(zip)
Owner
Björn Fahller
Björn Fahller
Googletest - Google Testing and Mocking Framework

GoogleTest OSS Builds Status Announcements Release 1.10.x Release 1.10.x is now available. Coming Soon Post 1.10.x googletest will follow Abseil Live

Google 28.8k Jan 9, 2023
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Catch Org 16k Jan 9, 2023
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)

lest – lest errors escape testing This tiny C++11 test framework is based on ideas and examples by Kevlin Henney [1,2] and on ideas found in the CATCH

Martin Moene 355 Dec 28, 2022
C++ Unit Testing Easier: A Header-only C++ unit testing framework

CUTE C++ Unit Testing Easier: A Header-only C++ unit testing framework usually available as part of the Cevelop C++ IDE (http://cevelop.com) Dependenc

Peter Sommerlad 36 Dec 26, 2022
Header-only C++11 library for property-based testing.

autocheck Header-only C++11 library for QuickCheck (and later, SmallCheck) testing. Please consult the wiki for documentation. Install conan remote ad

John Freeman 120 Dec 22, 2022
C unit tests with a small header-only library.

C unit tests Minimalistic unit tests in C. Uses the __attribute__((constructor)) which, as far as I know, is supported by GCC and clang. So this proba

Ruben van Nieuwpoort 62 Dec 5, 2022
The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch Windows All dev branch Windows All doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of

Viktor Kirilov 4.5k Jan 4, 2023
A complete unit testing framework in a header

liblittletest A complete unit testing framework in a header liblittletest is an easy to use all-in-an-header testing framework; all you have to do in

Sebastiano Merlino 13 Nov 11, 2021
Upp11 - C++11 lightweight single header unit test framework

upp11 Lightweight C++11 single header unit test framework To use framework: Copy upp11.h in you project dir. Create unit test source files or modify e

Andrey Valyaev 8 Apr 4, 2019
The fastest feature-rich C++11/14/17/20 single-header testing framework

master branch dev branch doctest is a new C++ testing framework but is by far the fastest both in compile times (by orders of magnitude) and runtime c

null 4.5k Jan 5, 2023
Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20

ankerl::nanobench ankerl::nanobench is a platform independent microbenchmarking library for C++11/14/17/20. #includ

Martin Leitner-Ankerl 909 Dec 25, 2022
C++ xUnit-like testing framework without macros

tst C++ testing framework. Installation, documentation, tutorials See WiKi. Features xUnit-like concepts minimal use of preprocessor macros declarativ

cppfw 9 Sep 26, 2022
TestFrame - This is a test framework that uses Raylib and ImGui together to help test and develop concepts

This is a test framework that uses Raylib and ImGui together to help test and develop concepts. It is made using C++ because it uses classes for windows and views.

Jeffery Myers 22 Dec 29, 2022
c++ testing framework

iutest iutest - iris unit test framework Welcome to the iutest iutest is framework for writing C++ tests. Features An XUnit test framework. Header onl

srz_zumix 60 Sep 12, 2022
UT: C++20 μ(micro)/Unit Testing Framework

"If you liked it then you "should have put a"_test on it", Beyonce rule UT / μt | Motivation | Quick Start | Overview | Tutorial | Examples | User Gui

boost::ext 956 Jan 3, 2023
Modern c++17 unit testing framework on Microsoft Windows, Apple macOS, Linux, iOS and android.

tunit Modern c++17 unit testing framework on Windows, macOS, Linux, iOS and android. Continuous Integration build status Operating system Status Windo

Gammasoft 8 Apr 5, 2022
Simple C testing framework

MrTest Simple C testing framework Usage Copy the mrtest.c and mrtest.h file into your project. In order to use the mrtest main: create a .c file that

Maarten Raasveldt 2 Jul 20, 2022
End to end test framework designed for Juce applications

JUCE End to End test framework What is it? This package provides a mechanism to end-to-end test a JUCE application Prerequisites CMake. Must be 3.18 o

Focusrite Audio Engineering Ltd. 58 Jan 6, 2023
Various Framework to do Unit Test in C++

Unit Test in C++ There are many frameworks to performs unit test in C++, we will present the most popular ones and show how to use them. The testing f

Yassine 2 Nov 18, 2021