DescriptionCurrently GoogleTest allows the following highly convenient syntax:
TEST(Foo, test) {
EXPECT_EQ(NULL, SomeNullReturningFunc());
}
However it does not allow the opposing expectation to be made:
TEST(Foo, test) {
EXPECT_NE(NULL, SomeNonNullReturningFunc());
}
This patch adds the latter to the expectation system in precisely the same way as the _EQ variant. That said, this patch is extremely sub-optimal, as it completely duplicates the EqHelper as NotEqHelper with the only substantive change calling CmpHelperNE instead of CmpHelperEQ. This can be trivially accomplished by passing a function pointer, but that seems undue run-time overhead. I attempted to unify them through an added template parameter to provide the CmpHelper* method to be called, but that was non-trivial without using TR, C++0x, or Boost related helpers. Perhaps you can find a cleaner way Zhanyong?
This is also untested. I can certainly add the tests, but I didn't see a prime place for them, as EXPECT_EQ is never tested anywher. Thoughts?
Finally, the EXPECT_EQ() form has special (and IMO nicer) logging surrounding the idea of "expected" vs. "actual". I would personally enjoy extending this to EXPECT_NE() by using the idea of "unexpected" vs. "actual" terminology. I have already used those as more descriptive internal variables, but the logging refactoring would shuffle more around than I wanted in this change. I'd appreciate feedback on whether this is even desirable.
Patch Set 1 #
MessagesTotal messages: 1
|