Home | Libraries | People | FAQ | More |
BOOST_
level
_EQUAL_COLLECTIONS(
lhs_begin
,
lhs_end
, rhs_begin
,
rhs_end
)
compares two collections
for equality. Two collections are considered equal if they have the same
number of elements and the elements compare equal by operator==
. The elements are obtained through the
supplied iterators on the collections. The diagnostic message is constructed
from applying operator<<
to each of the elements in the collections.
Important | |
---|---|
If you get a strange compile error when using |
static std::list<int> generate_list() { std::list<int> l; l.push_front(3); l.push_front(2); l.push_front(1); return l; } BOOST_AUTO_TEST_CASE(example_equal_collections) { std::vector<int> expected; expected.push_back(1); expected.push_back(2); expected.push_back(3); std::list<int> actual = generate_list(); BOOST_REQUIRE_EQUAL_COLLECTIONS( expected.begin(), expected.end(), actual.begin(), actual.end()); } BOOST_AUTO_TEST_CASE(example_equal_collections_pod) { int const expected[] = { 1, 2, 3 }; std::list<int> actual = generate_list(); BOOST_REQUIRE_EQUAL_COLLECTIONS( &expected[0], &expected[sizeof(expected)/sizeof(expected[0])], actual.begin(), actual.end()); }