gazoni / googletest

Automatically exported from code.google.com/p/googletest
0 stars 0 forks source link

order agnostic error message #98

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A failed check like this

EXPECT_EQ( returns_1(), 0 );

creates output that looks like this.

somefile.cpp:42: Failure
Value of: 0
Expected: returns_1()
Which is: 1

The obvious fix is reorder my parameters.  However this won't fix every
case, consider

EXPECT_EQ( foo(), bar() );

I suggest using a format similar to one used in the terse output enhancement.

somefile.cpp:42: Failure
Expected: returns_1() == 0
  Actual: 1 != 0

The second example would produce

somefile.cpp:42: Failure
Expected: foo() == bar()
  Actual: 13 != 14

Original issue reported on code.google.com by j.nick.terry@gmail.com on 7 Jan 2009 at 7:15

GoogleCodeExporter commented 9 years ago
This is by-design and documented in the wiki (EXPECT_EQ(expected, actual)).

In testing, "expect A to be B" and "expect B to be A" are very different.  Being
asymmetric makes it explicit which value is being validated and which is the 
golden
value.  The order (expected, actual) is to be consistent with other xUnit-based
testing frameworks like JUnit and PyUnit.

Original comment by zhanyong...@gmail.com on 12 Jan 2009 at 8:55