jncornett / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

ASSERT_DATAEQ similar to ASSERT_STREQ #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
CxxTest has a macro called TS_ASSERT_SAME_DATA.  It is used to compare to
memory regions.

The macro would behave similar to ASSERT_STREQ does now, except it would
print the hex string of the memory regions if they differ.

This is particularly useful for testing POD structs that don't have an
equality or stream operator defined

Original issue reported on code.google.com by j.nick.terry@gmail.com on 3 Dec 2008 at 9:58

GoogleCodeExporter commented 9 years ago
The idea makes sense.  However, we'd like to control the number of macros, as 
macros 
are bad for many reasons.

Now that Google C++ Mocking Framework (http://code.google.com/p/googlemock/) is 
released, there is a better way to do it.  We can define a matcher BitEq(x) and 
write

  ASSERT_THAT(value, BitEq(x))

to assert that the bytes in value and the bytes in x are equal.  ASSERT_THAT() 
is 
already defined by Google Mock, so there's no new macro to add.  BitEq(x) can 
also be 
used in validating mock function arguments, so it's more useful than an 
ASSERT_DATAEQ 
macro too.

Note that you don't have to use Google Mock's mocking functionality in order to 
use 
ASSERT_THAT().

Original comment by shiq...@gmail.com on 16 Dec 2008 at 4:16

GoogleCodeExporter commented 9 years ago
This is tracked by Google Mock's issue 6: 
http://code.google.com/p/googlemock/issues/detail?id=6

Original comment by shiq...@gmail.com on 16 Dec 2008 at 6:21