Skip to main content
Best practices
0 votes
5 replies
77 views

I am working on a C++ code base that has a function called "getConfigFilePath()" in name space "utils" which returns the file path to a config file. The config file is really hard-...
feeling_lonely's user avatar
1 vote
1 answer
43 views

I have a class that has two functions with the same name and number of arguments. I wish to provide a default return value via ON_CALL. From reading around the matcher code - I have come to a partial ...
Danaldo's user avatar
  • 136
1 vote
1 answer
82 views

Since I learnt to use Google Test/Mock framework, I allways used the form to setup an expectation as following: EXPECT_CALL( mock_obj, mock_method ).WillOnce( Invoke( []() { do_things; } ) ); Few ...
Leon's user avatar
  • 2,165
0 votes
1 answer
69 views

I am using the WillByDefault(testing::Throw(...)) trick to terminate the test early, as described in https://stackoverflow.com/a/79534623/2894535 However, it seems to randomly trigger in some cases, ...
Dominik Kaszewski's user avatar
5 votes
1 answer
89 views

I want to test a function where one of its mocks should return alternating values many times. So e.g. I need something like this: EXPECT_CALL(my_mock, foo(_)) .WillOnce(Return(A)) .WillOnce(...
slingeraap's user avatar
0 votes
1 answer
46 views

I am trying to create a gmock matcher for a structure which contains bitfields: struct s { uint32_t x; uint32_t y : 12; uint32_t z : 20; }; I can create a testing::Field(&s::x, ...
Dominik Kaszewski's user avatar
5 votes
1 answer
444 views

Is there an equivalent to ASSERT_* for EXPECT_CALL, which ends the test on first uninteresting/unmatched call? I am using gtest+gmock to test HW register programming sequences, so all EXPECT_CALL are ...
Dominik Kaszewski's user avatar
2 votes
1 answer
63 views

I have a set of calls which I want to check in order, but they may be arbitrarily interspersed with a call to a log method. How can I tell gmock that that particular method can be called any number of ...
Dominik Kaszewski's user avatar
0 votes
0 answers
99 views

Since updating GTest framework from 1.8.x to 1.12.x, there have been a few tests that report memory leaks at the end of the test. I've stripped out all the complexity of our setups to the example ...
Pete Roberts's user avatar
3 votes
1 answer
139 views

This question is a follow-up on Google mock with unique_ptr object giving memory leak issue. My class under test takes owenership of the unique_ptr on its contructor: class Foo { public: virtual ...
Leonardo's user avatar
  • 2,020
0 votes
0 answers
69 views

I have the following setup for unit testing using googletest/gmock. class MockClass{ public: MOCK_METHOD0(log, void()); // -> this is fine MOCK_METHOD3(fcntl, int(int fd, int cmd, void* ...
Justplayit's user avatar
2 votes
1 answer
102 views

i started unit-test with gtest and gmock. I want to test the content of an EXPECT_CALL in one line. How to do it the right way? My example code: class MockClientSignalEventHandler : public ...
extreme001's user avatar
0 votes
1 answer
123 views

In very short: the issue I face is that in an ON_CALL(...).WillByDefault(DoAll(..some capture..,Invoke([&captureValues]{..trace them...}))); the capture only works reliably if that "Invoke&...
Robin Holenweger's user avatar
0 votes
2 answers
154 views

I have searched on this and did not find much information. I have a below pattern of code where I have 1 class dedicated to load and unload dll in constructor and destructor respectively. Also the ...
Shreya Acharya's user avatar
2 votes
1 answer
278 views

An operation will trigger another thread to call an expected fn(). Is that possible that main thread wait until the expectation meet? EXPECT_CALL(mockObj, fn()).Times(1); // operation will trigger ...
hczstev's user avatar
  • 93

15 30 50 per page
1
2 3 4 5
79