All Questions

8
votes
3answers
10042 views

Mock non-virtual method C++ (gmock)

I have class class CSumWnd : public CBaseWnd { private: bool MethodA() } Please can you help how to mock MethodA() without making virtual, I didn't understand the concept of hi-perf dependency i...
12
votes
2answers
2127 views

Teach Google-Test how to print Eigen Matrix

Introduction I am writing tests on Eigen matrices using Google's testing framework Google-Mock, as already discussed in another question. With the following code I was able to add a custom Matcher t...
10
votes
2answers
9754 views

how to set custom ref-variable in gmock

I am using gmock in my project and I meet a problem to set a custom reference variable for a mock function. Suppose I have a class as following: class XXXClient { public: void QueryXXX(const Requ...
6
votes
1answers
8786 views

Google mock ByRef method

I have a class that takes a boolean as a reference parameter and returns an integer: class Foo { public: Bar my_bar; virtual int myMethod(bool &my_boolean) = 0; } /*...*/ int Foo::myM...
6
votes
3answers
2376 views

Compare Eigen matrices in Google Test or Google Mock

I was wondering if there is a good way to test two Eigen matrices for approximate equality using Google Test, or Google Mock. Take the following test-case as a simplified example: I am multiplying tw...
5
votes
2answers
1784 views

Can a mock class inherit from another mock class in googlemock?

Can a mock class inherit from another mock class in googlemock? If yes, then please help me in understanding why isn't this working. class IA { public: virtual int test1(int a) = 0; }; class IB :...
4
votes
4answers
2132 views

Can gmock be used for stubbing C functions?

I am new to gmock, so I want to know how can I stub simple C function called in a function under test for Unit Testing. Example: int func(int a) { boolean find; // Some code find = func_1(); ...
1
votes
1answers
346 views

How to gmock functions in the same class when they call each other

Suppose here is the case: class base() { virtual func1()=0; virtual func2()=0; virtual func3()=0; } class Inheritance:public base { virtual func1(){ func2(); func3() }; virtual func2()...
5
votes
1answers
444 views

Dependency injection with unique_ptr to mock

I have a class Foo that uses class Bar. Bar is used only in Foo and Foo is managing Bar, therefore I use unique_ptr (not a reference, because I don't need Bar outside of Foo): using namespace std; st...
5
votes
1answers
3733 views

How to use gmock to test that a class calls it's base class' methods

class Foo { public: int x; int y; void move(void); }; class SuperFoo: public Foo { public: int age; void update(); }; SuperFoo::update(void) { move(); age++; } I'm ju...

Previous Next