googlemock Questions

0

I'm trying to test two serial port write+read calls. The first one has to block on read for 101ms and thus cause a timeout error. The second one should run fine. Based on the google mock manual the...
Bulldoze asked 21/3, 2017 at 22:20

3

I want to mock malloc in C++ using Gmock framework. Is it possible? I have tried all possible ways. But the class which is hosting this malloc implementation has got a private constructor and destr...
Binate asked 15/7, 2013 at 22:6

2

Solved

If an interface has a function to create an object with deleted copy-ctor, how to mock this function? Gmock seems to use the object's copy constructor internally. E.g. // The object with deleted ...
Shopper asked 28/2, 2017 at 9:39

1

Solved

I have a class Foo that stores a pointer to a callback. The callback could be invoked with a method InvokeCallback(). void* SomeCallback(void* a) { return (void*)(*(int*)a + 10); } class Foo ...
Uniaxial asked 16/2, 2017 at 6:37

1

Solved

I am writing a server/client based C++ application in Ubuntu with BSD socket. I am using Google C++ Test Framework as my unit test framework. I wonder is there a way that I can create a serv...
Kalman asked 19/1, 2017 at 23:22

1

Solved

I am studying in the gmock. Now Im trying to mock the class named "task", like this: class MockTask : public Task { public: MOCK_METHOD3(Execute, bool(std::set<std::string> &setDeviceID...
Aubry asked 5/9, 2016 at 3:4

3

Solved

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...
Chavis asked 2/8, 2014 at 12:22

0

I am trying to create unit tests using boost::test and google mock. Adding a call to InitGoogleMock causes boost to signal some memory leaks. I searched for some sort of "DeInitGoogleMock" but didn...

3

I have a mock function: MOCK_METHOD4(my_func, int(double, double, void* (*cb) (int), int p1)); I want to invoke 2nd (0-based) argument of above function with the 3rd argument as parameter, i.e.,...
Reiterate asked 7/7, 2016 at 7:19

1

When I use Google Test and Google Mock, with diagnostic level set to "info", I get messages like this: Uninteresting mock function call - taking default action specified at: src/pkgtest/test_Foo.c...
Diondione asked 14/6, 2016 at 14:0

3

Solved

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 ...
Hydrazine asked 25/4, 2011 at 11:5

2

I having difficulty saving a pointer argument that my mock receives. #define SIZE_OF_DATA typedef struct { uint32_t someValue1; uint16_t someValue2; // other values here } LargeStruct; class...
Cisco asked 17/9, 2014 at 12:0

2

Solved

I have mocked virtual method returning istream&. I'd like to use it in a testcase. How to return some value? The problem is that istream is noncopyable. I try something like this: TEST(x, y)...
Gryphon asked 30/3, 2016 at 11:51

3

Solved

For this special scenario, I am not able to get rid of the leaks. I get the message of Leaked Mock Objects when executing the test. The concrete Message: ClassElementFixture.h:102: ERROR: this mo...
Porter asked 6/9, 2012 at 8:29

1

Solved

I am trying to set a class member function parameter value in Google Mock, but I get build errors and I simply don't understand what is going on. Would it be possible for someone to explain please....
Suffocate asked 10/2, 2016 at 10:9

0

I'm looking for strategies to improve my build times with googletest and am wondering if what I'm seeing is typical, if there's a particular feature that can be avoided to improve build times, or i...
Leeannaleeanne asked 31/1, 2016 at 1:55

1

Solved

I'm using Google Mock (gMock) for the first time. Given the following code snippet: class LinkSignals { public: virtual ~LinkSignals() { } virtual void onLink(std::string) = 0; virtual void o...
Middlebrooks asked 19/1, 2016 at 19:59

1

Solved

Using Google Test, I need a way to verify that a string that was returned by my class under test does not contain a particular string. I can currently test that a string does contain another string...
Sanctified asked 14/1, 2016 at 22:49

1

Solved

How do I mock the following code? class ISomeClass { public: virtual ~ISomeClass() {} = 0; virtual const MyType & getType() const = 0; virtual MyType & getType() = 0; }; I have tried ...
Phile asked 10/12, 2015 at 8:19

2

Solved

Has anyone successfully built gmock and gtest in Visual Studio 2010? I've tried with version 1.5.0, but I only get incomprehensible compilation errors.
Badderlocks asked 29/6, 2010 at 14:47

1

I am trying to set expectation on a gmock object. The expectation should apply whenever "avout" is passed as an argument to my method. I set up the expectation like this: EXPECT_CALL(actx_mock, ge...
Clomp asked 2/11, 2015 at 16:43

3

Solved

I have a mock object setup that looks like this: MyObject obj; EXPECT_CALL(obj, myFunction(_)) .WillOnce(Return(1)) .WillOnce(Return(1)) .WillOnce(Return(1)) .WillRepeatedly(Return(-1)); Is ther...
Ebullient asked 7/8, 2013 at 19:45

1

Solved

I have two unit tests that share some state (unfortunately I can't change this since the point is to test the handling of this very state). TEST(MySuite, test1) { shared_ptr<MockObject> fir...
Rudbeckia asked 14/10, 2015 at 12:56

1

I'm trying to add unit tests and mocks to a legacy project. As part of this I partially mocked one of the classes, mocking just the methods that I need in the class I'm currently testing. I then pa...
Calcific asked 9/10, 2015 at 20:24

1

Solved

I have an interface class say: class MyInterface { public: virtual int doThing(int x, int y, int z) = 0; }; I want to write a mock implementation for use in my tests. E.g.Traditionally, without...
Zoila asked 30/9, 2015 at 18:46

© 2022 - 2024 — McMap. All rights reserved.