gmock


gmock matcher doesn't match my arguments by reference


I have a mocked function in a class like
int foo(const bar& b) const;
which is mocked like
MOCK_CONST_METHOD1(foo, int(const bar& b));
for which I've set set some default actions like
ON_CALL(anObject, foo(bar(0,0))).WillByDefault(Return(1));
My code under test calls
anObject.foo(bar(0,0);
but instead of returning 1, gmock gives me the following error:
Uninteresting mock function call - returning default value.
Function call: foo(#0xbfffcf90 8-byte object <00-00 00-00 00-00 00-00>)
The mock function has no default action set, and its return type has no default value set.
The operator == is defined for the object bar. Why can't gmock find my default actions?
The error was not in the code above. The ON_CALLstatement was after the code on test.
Simple answer: Be sure to have the ON_CALL statements before any code calls the mocked methods.

Related Links

gmock ReturnRef returns compilation error
How to call function pointer which is passed to Mock method?
In gmock, Is there a way to have mock object return an instance of an user defined object?
GMock testing destructor calls
set EXPECT_CALL to redirect the call to the original method
Capture GMOCK string parameter
Mocking non-virtual method generating errors
gmock matcher doesn't match my arguments by reference
What did you do to solve gmock you mentioned (link enclosed)?
how to set custom ref-variable in gmock

Categories

HOME
go
assembly
cobalt
amp-html
case
oracle-apex-5
package
socket.io
grafana
rendering
google-cloud-functions
maxscript
angularfire2
p2p
little-proxy
java.util.logging
alamofire
emoji
angular-dart
bitnami
altera
firefox-addon
digital-signature
symbols
drive
microsoft-ocr
kendo-mobile
ksh
named-entity-recognition
mongoid6
qliksense
epsilon
dapper-extensions
moses
licensing
soot
bringtofront
autodesk-designautomation
postback
fstream
wacom
hreflang
hard-drive
gojs
twos-complement
sendbird
dynamic-jasper
python-import
magento-1.9.2.4
modernizr
z-notation
apns-php
health-monitoring
google-data-api
plaintext
skylink
parser-generator
naming
movilizer
sharp-snmp
subclipse
jboss-4.2.x
user-defined-fields
modelsim
android-testing
mouseleave
gpg-signature
template-toolkit
mathcad
ampps
omxplayer
actor-platform
ziparchive
mongodb-php
nikeplus-api
i386
android-dateutils
appscale
pre-build-event
nservicebus5
lz77
asyncdisplaykit
character-replacement
dynamics-nav-2016
grgit
java-money
dllimport
computer-architecture
django-urls
intel-c++
canalyzer
evolus-pencil
botan
osc
rrule
theos
easyrtc
build-script
twitter-bootstrap-rails
xmltodict
away3d
isqlquery
scringo
nebula
actiondispatch
traceability
alice
bjyauthorize
wimax
midlet
subgraph
extconf.rb
window-decoration
stress
convention
pinch
role
workflow-services
promotion-code
jqote
unattended-processing
twitterizer
mtu
uideviceorientation
binomial-heap
aspmenu
dsl-tools

Resources

Encrypt Message