Closed GoogleCodeExporter closed 9 years ago
ASSERT/EXPECT_EQ prints its arguments by streaming to ostream (see
http://code.google.com/p/googletest/wiki/GoogleTestPrimer). The ostream by
default formats integers in decimal format. You can either define a class such
as this:
class Hex {
public:
explicit Hex(int n) : number_(n) {}
operator int() { return number; }
private:
int number_;
};
then define an operator to stream Hex as a hexadecimal and then
EXPECT_EQ(Hex(expected), Hex(actual)) will print values in hexadecimal.
If you prefer a more robust approach (and not typing Hex everywhere), you can
write
a macro that prints comparison values in hex. See
http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide#Using_a_Pred
icate-Formatter for more details.
Original comment by vladlosev
on 12 Nov 2009 at 6:39
Original issue reported on code.google.com by
giris...@gmail.com
on 12 Nov 2009 at 5:07