Google Test assertions ASSERT_*
are supposed to be used in the form of ASSERT_EQ(expected, actual)
where the 1st parameter is expected value and the 2nd is actual value. But very often I see in existing codebase that these parameters are reversed like in this code:
TEST(test, test)
{
ASSERT_EQ(foo(), 1);
}
This is almost ok, but it produces a bit weird error message in case of test failure like: "the result of foo()
was expected but actually it was 1
". This seems to be a minor issue but is there any way to force correct order of expected and actual at compile time?