Skip to content

Commit 2648a1b

Browse files
committed
Allow per-element comparison of string against non-string iterable (of char).
Test.
1 parent aaacf00 commit 2648a1b

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

include/boost/test/tools/collection_comparison_op.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,9 @@ compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GE<L, R> >*
387387
template<typename Lhs,typename Rhs> \
388388
struct name<Lhs,Rhs,typename boost::enable_if_c< \
389389
unit_test::is_forward_iterable<Lhs>::value \
390-
&& !unit_test::is_cstring_comparable<Lhs>::value \
391390
&& unit_test::is_forward_iterable<Rhs>::value \
392-
&& !unit_test::is_cstring_comparable<Rhs>::value>::type> { \
391+
&& !(unit_test::is_cstring_comparable<Lhs>::value \
392+
&& unit_test::is_cstring_comparable<Rhs>::value)>::type> { \
393393
public: \
394394
typedef assertion_result result_type; \
395395
typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator_helper; \

test/writing-test-ts/collection-comparison-test.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ BOOST_AUTO_TEST_CASE( test_collection_of_collection_comp )
142142

143143
//____________________________________________________________________________//
144144

145+
BOOST_AUTO_TEST_CASE( test_per_element_string_non_string )
146+
{
147+
std::string a("abc");
148+
std::vector<char> b{'a', 'b', 'c'};
149+
BOOST_TEST( a == b, tt::per_element() );
150+
BOOST_TEST( b == a, tt::per_element() );
151+
}
152+
153+
//____________________________________________________________________________//
154+
145155
// this one does not have const_iterator nor a size, but should be forward iterable
146156
// and possible to use in the collection comparison
147157
struct fwd_iterable_custom {

0 commit comments

Comments
 (0)