2

I want to isolate writeMemory but i can't because of the following error:

../../Util/UnitTest++/../../UnitTests/KeeperDive_Test.h:66:57: error: expected expression mocks.ExpectCall(Skillmock, Skill::writeMemory).With(template (Skillmock));

class Skill
{
protected:
    template <class T> void writeMemory(const char *key, T value)
    {
        PY_ERROR_TRY
        {
            skillMemory[key] = (T)value;
        }
        PY_ERROR_CATCH
    }
};

TEST(run)
{    
    MockRepository mocks;
    Skill *Skillmock = mocks.Mock<Skill>();
    mocks.ExpectCall(Skillmock, Skill::writeMemory).With(template<class T>(Skillmock));
}
Axalo
  • 2,953
  • 4
  • 25
  • 39

1 Answers1

0

You cannot expect a call on a template method - only on a specific instance of the method. For this case you'll also not be able to mock a non-virtual class member, in part because that's not implemented but mostly because this instance would be fully inlined anyway, and cannot be mocked out afterwards.

dascandy
  • 7,184
  • 1
  • 29
  • 50