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

Crash when faking a templated method #69

Open xpac27 opened 8 years ago

xpac27 commented 8 years ago

Given the following classes:

class A {
    public:
        virtual ~A() {}
        template<typename T> void foo() {}
};

class B {};

The following does compile correctly:

Mock<A> a;
Fake(Method(a, foo<B>));

But when ran the test executable stops because of EXC_BAD_ACCESS:

  * frame #0: 0x000000010010bea7 tests` fakeit::DynamicProxy<playercommunity::command::Command>::isBinded(unsigned int) [inlined] std::__1::shared_ptr<fakeit::Destructible>::shared_ptr(this=0x00007fff5fbfc5a8, __r=0x00000001037d17d0)  + 4 at memory:4250
    frame #1: 0x000000010010bea3 tests` fakeit::DynamicProxy<playercommunity::command::Command>::isBinded(unsigned int) [inlined] std::__1::shared_ptr<fakeit::Destructible>::shared_ptr(this=0x00007fff5fbfc5a8, __r=0x00000001037d17d0)  + 16 at memory:4252
    frame #2: 0x000000010010be93 tests` fakeit::DynamicProxy<playercommunity::command::Command>::isBinded(this=0x00007fff5fbfd668, offset=2281792)  + 67 at fakeit.hpp:16449

ect... up to the line where I fake method foo. Isn't faking templated method supported? :(

tnovotny commented 8 years ago

AFAIK only virtual methods can be faked. Template methods cannot be virtual, so I guess the answer is no.

xpac27 commented 8 years ago

Hum... Yes, makes sense.