vendredi 24 avril 2015

mocking: extracting arguments to a function to create another function with same signature

I am mocking a class A. It has 15 virtual functions that i want to override and call passed lambdas from that.

Code is:

struct A {
   virtual int funcA(int , int) ;
   virtual void funcB(double) ;
   // ... more..
};

Mock Class:

struct MockA : public A {
    std::function<decltype(funcA)> lambdaA;
    virtual decltype(((A*)nullptr)->funcA()) funcA(/* How to get aruments*/) override {
        return lambdaA(/* How to forward the arguments. */);
    }
};

I can not understand how to get arguments and forward them to lambdaA ?

Aucun commentaire:

Enregistrer un commentaire