toeb / googletest

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

Enhancement: comparison between containers #231

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The google test framework includes no easy way to compare between containers of 
numbers. I have 
a potential solution that would be improved by inclusion in the googletest 
framework (and more 
direct access to the macros and templated functions).

I posted my solution on SO:
http://stackoverflow.com/questions/1460703/comparison-of-arrays-in-google-
test/1681550#1681550

and I'm attaching my own copy of the source.

Original issue reported on code.google.com by johnson.seth.r@gmail.com on 2 Dec 2009 at 2:18

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for the contribution, Johnson.

In general, we try to avoid new macros as they are nasty.  Also, we encourage 
people
to use Google Mock, which is like a superset of Google Test.  Google Mock lets 
you
compare two containers like:

  EXPECT_THAT(my_container, ContainerEq(expected_container));

or (when the container is small):

  EXPECT_THAT(my_container, ElementsAre(1, 3, _, Lt(5)));
  // Element 1 must be 1; element 2 must be 3,
  // element 3 can be anything, and element 4 must be less than 5.

We may even move EXPECT_THAT and friends from Google Mock to Google Test in the
future.  Therefore we don't want to add new macros to do container comparison 
now.

Original comment by w...@google.com on 3 Dec 2009 at 4:45

GoogleCodeExporter commented 9 years ago
Thanks for the feedback. I wasn't aware of that framework.

Original comment by johnson.seth.r@gmail.com on 3 Dec 2009 at 4:52