Pretty print GetParam() when it's a user defined type

2,043 views
Skip to first unread message

Dan Filimon

unread,
Aug 24, 2011, 6:08:53 PM8/24/11
to googletes...@googlegroups.com
I'm a really big fan of value-parameterized tests and I've usually been fine with basic values as parameters.

Recently though I've started using more complicated test cases and even though everything works fine, if an assertion fails, GetParam() is printed  using the default printer:
GetParam() = 48-byte object <00-7C 57-00 00-00 00-00 03-00 00-00 01-00 00-00 00-00 00-00 00-00 00-00 01-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 20-00 00-00 7F-00 00-00>

I've added an operator<< to my test case type, but this doesn't seem to be helping.

Any suggestions?

Vlad Losev

unread,
Aug 25, 2011, 5:42:53 PM8/25/11
to googletes...@googlegroups.com
See http://code.google.com/p/googletest/wiki/AdvancedGuide#Teaching_Google_Test_How_to_Print_Your_Values. Make sure to define the printing function in the same namespace where the class you are printing is defined.
Reply all
Reply to author
Forward
0 new messages