Dale King wrote:
There is a NotNull matcher but not an IsNull matcher. The docmentation
says just use the value NULL for matching against NULL, but that
doesn't work in all cases in Microsoft C++ and possibly other
languages..
So a statement like:
EXPECT_THAT( thePointer, NULL );
does not compile in MSVC. These do not compile either:
EXPECT_THAT( thePointer, (void *)NULL );
EXPECT_THAT( thePointer, Eq( NULL ) );
If I cast NULL to the pointer's type it will work.
Of course, I can (and have) expressed this simple case as
EXPECT_EQ( NULL, thePointer );
and that works. But sometimes you really need a matcher and cannot use
EXPECT_EQ. The lack of symmetry here bugs me. I can say the opposite
with a matcher:
EXPECT_THAT( thePointer, NotNull() );
But cannot express check for null with a matcher other than by using
the double negative Not( NotNull() ).
It would be very nice to be able to just say:
EXPECT_THAT( thePointer, IsNull() );
Original issue reported on code.google.com by zhanyong...@gmail.com on 23 Sep 2009 at 4:06
Original issue reported on code.google.com by
zhanyong...@gmail.com
on 23 Sep 2009 at 4:06