Bug #156

ASSERT_EQUAL_RANGE

Added by Thomas Corbat almost 2 years ago. Updated almost 2 years ago.

Status:ResolvedStart date:03 Dec 2015
Priority:NormalDue date:07 Dec 2015
Assignee:Peter Sommerlad% Done:

100%

Category:Headers
Target version:Headers 2.1

Description

It might be nice to be able to compare ranges to the same type.

std::vector<std::string> expected{"a", "b", "c"};
std::set<std::string> actual{"b", "a", "c"};

ASSERT_EQUAL_RANGE(std::begin(expected), std::end(expected), std::begin(actual), std::end(actual));
ASSERT_EQUAL_RANGEM("I'd never expect this to fail!", std::begin(expected), std::end(expected), std::begin(actual), std::end(actual));

Comparsion is not an issue. It can be easily asserted with std::equal(), but that does not display a nifty message (as for example the comparison of std::vector.

History

#1 Updated by Peter Sommerlad almost 2 years ago

would this be what is wanted. I extended it to work also with initializer_list:
void testRangesEqualSimple(){
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(1);
ASSERT_EQUAL_RANGES(v.begin(),v.end(),v.rbegin(),v.rend());
}

#ifdef USE_STD11
void testRangesFromInitializerList(){
std::vector<int> v{1,2,3};
ASSERT_EQUAL(cute::make_range({1,2,3}),v);
}

#endif

#2 Updated by Peter Sommerlad almost 2 years ago

  • Status changed from New to Resolved

#3 Updated by Peter Sommerlad almost 2 years ago

  • Due date set to 07 Dec 2015
  • % Done changed from 0 to 100

Also available in: Atom PDF