eranpeer / FakeIt

C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.
MIT License
1.24k stars 170 forks source link

Doesn't compile with Catch 1.2.1 #121

Open Elemental239 opened 6 years ago

Elemental239 commented 6 years ago

FakeIt's single_header/catch doesn't compile with Catch 1.2.1 cause of no "Catch::AssertionHandler" object.

Elemental239 commented 6 years ago

Addition: I've tried to add fakeit as standalone. I am using VS Community 14.0.25431.01 Update 3 with catch 1.2.1.

Even the first example doesn't work:

struct SomeInterface { virtual int foo(int) = 0; virtual int bar(int, int) = 0; }; Mock mock; // Stub a method to return a value once When(Method(mock, foo)).Return(1);

This doesn't compile with errors "no instance of function template "fakeit::WhenFunctor::operator()" matches the argument list"
"Error C3640 'C_A_T_C_HT_E_S_T__5::SomeInterface::[thunk]: thiscall void __cdecl ____C_A_T_C_H____T_E_S_T____5(void)'::2'::SomeInterface::`vcall'{0,{flat}}' }'': a referenced or virtual member function of a local class must be defined"

Update of 29.12: I've got it compiling. The problem was with interface declaring inside the function with the mock itself. After I moved SimeInterface declaration out of the method, it compiled.

bu5hm4nn commented 6 years ago

The current version of FakeIt is meant to run with Catch v2. I have it running with v. 2.0.1. If you want to use older versions of Catch, find an older version of FakeIt in the commit log.