From 3bc56800cdda6bcec8b0514cac1d7939f0c74472 Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sat, 11 Feb 2017 15:03:45 +0100 Subject: [PATCH 01/11] Added BOOST_TEST_ALL_EQ macro to compare container contents --- doc/lightweight_test.qbk | 9 ++++++ include/boost/core/lightweight_test.hpp | 41 +++++++++++++++++++++++++ test/lightweight_test_test.cpp | 10 ++++++ 3 files changed, 60 insertions(+) diff --git a/doc/lightweight_test.qbk b/doc/lightweight_test.qbk index c7ef180..c3ab7bc 100644 --- a/doc/lightweight_test.qbk +++ b/doc/lightweight_test.qbk @@ -38,6 +38,7 @@ When using `lightweight_test.hpp`, *do not forget* to #define BOOST_TEST_NE(expr1, expr2) /*unspecified*/ #define BOOST_TEST_CSTR_EQ(expr1, expr2) /*unspecified*/ #define BOOST_TEST_CSTR_NE(expr1, expr2) /*unspecified*/ +#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) /* unspecified */ #define BOOST_TEST_THROWS(expr, excep) /*unspecified*/ namespace boost @@ -121,6 +122,14 @@ BOOST_TEST_CSTR_NE(expr1, expr2) Specialization of BOOST_TEST_NE which interprets expr1 and expr2 as pointers to null-terminated byte strings (C strings). If `std::strcmp(expr1, expr2) == 0`, increase the error count and output a message containing both expressions. +[section BOOST_TEST_ALL_EQ] + +`` +BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) +`` + +Compares the content of two containers. If they have different sizes, or if any pairwise element differs, increases the error count and outputs a message containing all differing elements. + [endsect] [section BOOST_TEST_THROWS] diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index d1766a4..d8a316e 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -19,6 +19,8 @@ // http://www.boost.org/LICENSE_1_0.txt // +#include +#include #include #include #include @@ -180,6 +182,43 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2, } } +template +void test_all_eq_impl(char const * file, int line, char const * function, + FwdIt1 first_begin, FwdIt1 first_end, + FwdIt2 second_begin, FwdIt2 second_end) +{ + if (std::distance(first_begin, first_end) != std::distance(second_begin, second_end)) + { + ::boost::detail::error_impl("Container sizes are different", __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); + } + else + { + FwdIt1 first_it = first_begin; + FwdIt2 second_it = second_begin; + std::ostringstream indices; + do + { + while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) + { + ++first_it; + ++second_it; + } + if (first_it == first_end) + { + boost::detail::report_errors_remind(); + return; + } + indices << " [" << std::distance(first_begin, first_it) << "] '" << *first_it << "' != '" << *second_it << "'"; + ++first_it; + ++second_it; + } while (first_it != first_end); + BOOST_LIGHTWEIGHT_TEST_OSTREAM + << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices" + << indices.str() << std::endl; + ++boost::detail::test_errors(); + } +} + #if defined(_MSC_VER) # pragma warning(pop) #elif defined(__clang__) && defined(__has_warning) @@ -225,6 +264,8 @@ inline int report_errors() #define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) +#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) ) + #ifndef BOOST_NO_EXCEPTIONS #define BOOST_TEST_THROWS( EXPR, EXCEP ) \ try { \ diff --git a/test/lightweight_test_test.cpp b/test/lightweight_test_test.cpp index a3b04a9..bfef152 100644 --- a/test/lightweight_test_test.cpp +++ b/test/lightweight_test_test.cpp @@ -8,6 +8,7 @@ // http://www.boost.org/LICENSE_1_0.txt // +#include #include struct X @@ -74,6 +75,15 @@ int main() BOOST_TEST_NE("xabc"+1, "yabc"+1); // equal cstrings, different addresses BOOST_TEST_CSTR_NE("x", "y"); + // BOOST_TEST_ALL_EQ + { + std::vector xarray; + xarray.push_back(1); + xarray.push_back(2); + std::vector yarray(xarray); + BOOST_TEST_ALL_EQ(xarray.begin(), xarray.end(), yarray.begin(), yarray.end()); + } + // BOOST_TEST_THROWS BOOST_TEST_THROWS( throw X(), X ); From 6a5f540f08e1aec51c8a6464046cfe5ab8fa77af Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sat, 11 Feb 2017 16:37:12 +0100 Subject: [PATCH 02/11] Removed std::ostringstream --- include/boost/core/lightweight_test.hpp | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index d8a316e..5e0ef5c 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -20,7 +20,6 @@ // #include -#include #include #include #include @@ -182,10 +181,11 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2, } } -template -void test_all_eq_impl(char const * file, int line, char const * function, - FwdIt1 first_begin, FwdIt1 first_end, - FwdIt2 second_begin, FwdIt2 second_end) +template +void test_all_eq_impl(FormattedOutputFunction& output, + char const * file, int line, char const * function, + ForwardIterator1 first_begin, ForwardIterator1 first_end, + ForwardIterator2 second_begin, ForwardIterator2 second_end) { if (std::distance(first_begin, first_end) != std::distance(second_begin, second_end)) { @@ -193,9 +193,9 @@ void test_all_eq_impl(char const * file, int line, char const * function, } else { - FwdIt1 first_it = first_begin; - FwdIt2 second_it = second_begin; - std::ostringstream indices; + ForwardIterator1 first_it = first_begin; + ForwardIterator2 second_it = second_begin; + bool first_iteration = true; do { while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) @@ -208,13 +208,16 @@ void test_all_eq_impl(char const * file, int line, char const * function, boost::detail::report_errors_remind(); return; } - indices << " [" << std::distance(first_begin, first_it) << "] '" << *first_it << "' != '" << *second_it << "'"; + if (first_iteration) + { + first_iteration = true; + output << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices"; + } + output << " [" << std::distance(first_begin, first_it) << "] '" << *first_it << "' != '" << *second_it << "'"; ++first_it; ++second_it; } while (first_it != first_end); - BOOST_LIGHTWEIGHT_TEST_OSTREAM - << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices" - << indices.str() << std::endl; + output << std::endl; ++boost::detail::test_errors(); } } @@ -264,7 +267,7 @@ inline int report_errors() #define BOOST_TEST_CSTR_EQ(expr1,expr2) ( ::boost::detail::test_cstr_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) #define BOOST_TEST_CSTR_NE(expr1,expr2) ( ::boost::detail::test_cstr_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) ) -#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) ) +#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) ) #ifndef BOOST_NO_EXCEPTIONS #define BOOST_TEST_THROWS( EXPR, EXCEP ) \ From 265583bc78bc5b62bbdc7a49c5a6ff30d38e9bbe Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sat, 11 Feb 2017 18:26:57 +0100 Subject: [PATCH 03/11] Fixed error output of test_all_eq_impl --- include/boost/core/lightweight_test.hpp | 23 ++++++++---- test/Jamfile.v2 | 1 + test/lightweight_test_fail11.cpp | 50 +++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 test/lightweight_test_fail11.cpp diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 5e0ef5c..e263e01 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -189,13 +189,13 @@ void test_all_eq_impl(FormattedOutputFunction& output, { if (std::distance(first_begin, first_end) != std::distance(second_begin, second_end)) { - ::boost::detail::error_impl("Container sizes are different", __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); + ::boost::detail::error_impl("Container sizes are different", file, line, function); } else { ForwardIterator1 first_it = first_begin; ForwardIterator2 second_it = second_begin; - bool first_iteration = true; + std::size_t error_count = 0; do { while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) @@ -205,20 +205,27 @@ void test_all_eq_impl(FormattedOutputFunction& output, } if (first_it == first_end) { - boost::detail::report_errors_remind(); - return; + break; // do-while } - if (first_iteration) + if (error_count == 0) { - first_iteration = true; output << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices"; } output << " [" << std::distance(first_begin, first_it) << "] '" << *first_it << "' != '" << *second_it << "'"; ++first_it; ++second_it; + ++error_count; } while (first_it != first_end); - output << std::endl; - ++boost::detail::test_errors(); + + if (error_count == 0) + { + boost::detail::report_errors_remind(); + } + else + { + output << std::endl; + ++boost::detail::test_errors(); + } } } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 31ba00f..fb9845f 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -78,6 +78,7 @@ run-fail lightweight_test_fail8.cpp ; run-fail lightweight_test_fail8.cpp : : : off : lightweight_test_fail8_no_rtti ; run-fail lightweight_test_fail9.cpp ; run-fail lightweight_test_fail10.cpp ; +run-fail lightweight_test_fail11.cpp ; run is_same_test.cpp ; diff --git a/test/lightweight_test_fail11.cpp b/test/lightweight_test_fail11.cpp new file mode 100644 index 0000000..474d307 --- /dev/null +++ b/test/lightweight_test_fail11.cpp @@ -0,0 +1,50 @@ +// +// Negative test for BOOST_TEST_ALL_EQ +// +// Copyright (c) 2017 Bjorn Reese +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// + +#include +#include + +int main() +{ + int test_cases = 0; + + { + std::vector x, y; + x.push_back( 1 ); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + { + std::vector x, y; + y.push_back( 1 ); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + { + std::vector x, y; + x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 ); + y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 ); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + { + std::vector x, y; + x.push_back( 1.0f ); x.push_back( 2.0f ); x.push_back( 3.0f ); x.push_back( 4.0f ); + y.push_back( 4.0f ); y.push_back( 2.0f ); y.push_back( 3.0f ); y.push_back( 1.0f ); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + boost::report_errors(); + + return boost::detail::test_errors() == test_cases; +} From c96ad4ccbaab46a8b492414eb2a622d096d62651 Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sat, 11 Feb 2017 18:39:06 +0100 Subject: [PATCH 04/11] Added container sizes to error output of test_all_eq_impl --- include/boost/core/lightweight_test.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index e263e01..4532819 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -187,9 +187,16 @@ void test_all_eq_impl(FormattedOutputFunction& output, ForwardIterator1 first_begin, ForwardIterator1 first_end, ForwardIterator2 second_begin, ForwardIterator2 second_end) { - if (std::distance(first_begin, first_end) != std::distance(second_begin, second_end)) + typename std::iterator_traits::difference_type first_distance = std::distance(first_begin, first_end); + typename std::iterator_traits::difference_type second_distance = std::distance(second_begin, second_end); + if (first_distance != second_distance) { - ::boost::detail::error_impl("Container sizes are different", file, line, function); + output << file << "(" << line << "): " + << "Container sizes are different" + << " in function '" << function << "': " + << first_distance << " != " << second_distance + << std::endl; + ++test_errors(); } else { From fb09632580fc0f4bfc17699ff44fdac0b0d5983c Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sun, 12 Feb 2017 12:26:58 +0100 Subject: [PATCH 05/11] Use test_output_impl in test_all_eq_impl --- include/boost/core/lightweight_test.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 4532819..8cc5547 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -218,7 +218,7 @@ void test_all_eq_impl(FormattedOutputFunction& output, { output << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices"; } - output << " [" << std::distance(first_begin, first_it) << "] '" << *first_it << "' != '" << *second_it << "'"; + output << " [" << std::distance(first_begin, first_it) << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'"; ++first_it; ++second_it; ++error_count; From db8efb4ce9818287bab3abe8c81455adfc3c5eaf Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sun, 12 Feb 2017 13:19:39 +0100 Subject: [PATCH 06/11] Changed ForwardIterator to InputIterator for test_all_eq_impl --- include/boost/core/lightweight_test.hpp | 93 ++++++++++++++----------- test/lightweight_test_fail11.cpp | 76 ++++++++++++++++++++ 2 files changed, 130 insertions(+), 39 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 8cc5547..8ed0f7d 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -181,58 +181,73 @@ inline void test_cstr_ne_impl( char const * expr1, char const * expr2, } } -template +template void test_all_eq_impl(FormattedOutputFunction& output, char const * file, int line, char const * function, - ForwardIterator1 first_begin, ForwardIterator1 first_end, - ForwardIterator2 second_begin, ForwardIterator2 second_end) + InputIterator1 first_begin, InputIterator1 first_end, + InputIterator2 second_begin, InputIterator2 second_end) { - typename std::iterator_traits::difference_type first_distance = std::distance(first_begin, first_end); - typename std::iterator_traits::difference_type second_distance = std::distance(second_begin, second_end); - if (first_distance != second_distance) + InputIterator1 first_it = first_begin; + InputIterator2 second_it = second_begin; + typename std::iterator_traits::difference_type first_index = 0; + typename std::iterator_traits::difference_type second_index = 0; + std::size_t error_count = 0; + do { - output << file << "(" << line << "): " - << "Container sizes are different" - << " in function '" << function << "': " - << first_distance << " != " << second_distance - << std::endl; - ++test_errors(); - } - else - { - ForwardIterator1 first_it = first_begin; - ForwardIterator2 second_it = second_begin; - std::size_t error_count = 0; - do + while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) { - while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) - { - ++first_it; - ++second_it; - } - if (first_it == first_end) - { - break; // do-while - } - if (error_count == 0) - { - output << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices"; - } - output << " [" << std::distance(first_begin, first_it) << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'"; ++first_it; ++second_it; - ++error_count; - } while (first_it != first_end); - + ++first_index; + ++second_index; + } + if ((first_it == first_end) || (second_it == second_end)) + { + break; // do-while + } if (error_count == 0) { - boost::detail::report_errors_remind(); + output << file << "(" << line << "): Container contents differ in function '" << function << "':"; + } + output << " [" << first_index << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'"; + ++first_it; + ++second_it; + ++first_index; + ++second_index; + ++error_count; + } while (first_it != first_end); + + while (first_it != first_end) + { + ++first_it; + ++first_index; + } + while (second_it != second_end) + { + ++second_it; + ++second_index; + } + if (first_index != second_index) + { + if (error_count == 0) + { + output << file << "(" << line << "): Container sizes differ in function '" << function << "': size(" << first_index << ") != size(" << second_index << ")"; } else { - output << std::endl; - ++boost::detail::test_errors(); + output << " [*] size(" << first_index << ") != size(" << second_index << ")"; } + ++error_count; + } + + if (error_count == 0) + { + boost::detail::report_errors_remind(); + } + else + { + output << std::endl; + ++boost::detail::test_errors(); } } diff --git a/test/lightweight_test_fail11.cpp b/test/lightweight_test_fail11.cpp index 474d307..120a859 100644 --- a/test/lightweight_test_fail11.cpp +++ b/test/lightweight_test_fail11.cpp @@ -9,18 +9,52 @@ // #include +#include #include int main() { int test_cases = 0; + // Array + + { + int x[] = { 1 }; + int y[] = { 1, 2 }; + BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) ); + ++test_cases; + } + + { + int x[] = { 1, 2 }; + int y[] = { 1 }; + BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) ); + ++test_cases; + } + + { + int x[] = { 2 }; + int y[] = { 1, 2 }; + BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) ); + ++test_cases; + } + + { + int x[] = { 1, 2, 3, 4 }; + int y[] = { 1, 3, 2, 4 }; + BOOST_TEST_ALL_EQ( x, x + sizeof(x)/sizeof(x[0]), y, y + sizeof(y)/sizeof(y[0]) ); + ++test_cases; + } + + // Vector + { std::vector x, y; x.push_back( 1 ); BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); ++test_cases; } + { std::vector x, y; y.push_back( 1 ); @@ -44,6 +78,48 @@ int main() ++test_cases; } + { + std::vector x, y; + x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); + y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 ); y.push_back( 4 ); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + { + std::vector x, y; + x.push_back( 1 ); x.push_back( 2 ); x.push_back( 3 ); x.push_back( 4 ); + y.push_back( 1 ); y.push_back( 3 ); y.push_back( 2 );; + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + // Set + + { + std::set x, y; + x.insert(1); + y.insert(1); y.insert(3); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + { + std::set x, y; + x.insert(1); x.insert(2); + y.insert(1); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + + { + std::set x, y; + x.insert(1); x.insert(2); + y.insert(1); y.insert(3); + BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() ); + ++test_cases; + } + boost::report_errors(); return boost::detail::test_errors() == test_cases; From d828e40f6d4d18ec6635d2ecff7cb2239e28dcf1 Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sun, 12 Feb 2017 15:06:31 +0100 Subject: [PATCH 07/11] Output at most 8 differing container values --- include/boost/core/lightweight_test.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 8ed0f7d..908cc77 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -192,6 +192,7 @@ void test_all_eq_impl(FormattedOutputFunction& output, typename std::iterator_traits::difference_type first_index = 0; typename std::iterator_traits::difference_type second_index = 0; std::size_t error_count = 0; + const std::size_t max_count = 8; do { while ((first_it != first_end) && (second_it != second_end) && (*first_it == *second_it)) @@ -209,6 +210,11 @@ void test_all_eq_impl(FormattedOutputFunction& output, { output << file << "(" << line << "): Container contents differ in function '" << function << "':"; } + else if (error_count >= max_count) + { + output << " ..."; + break; + } output << " [" << first_index << "] '" << test_output_impl(*first_it) << "' != '" << test_output_impl(*second_it) << "'"; ++first_it; ++second_it; From baed4103a069a6d06951ae06cf23c9ef2a31de73 Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sun, 12 Feb 2017 15:08:25 +0100 Subject: [PATCH 08/11] Optimized calculation of container sizes --- include/boost/core/lightweight_test.hpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/include/boost/core/lightweight_test.hpp b/include/boost/core/lightweight_test.hpp index 908cc77..b4b59c7 100644 --- a/include/boost/core/lightweight_test.hpp +++ b/include/boost/core/lightweight_test.hpp @@ -223,16 +223,8 @@ void test_all_eq_impl(FormattedOutputFunction& output, ++error_count; } while (first_it != first_end); - while (first_it != first_end) - { - ++first_it; - ++first_index; - } - while (second_it != second_end) - { - ++second_it; - ++second_index; - } + first_index += std::distance(first_it, first_end); + second_index += std::distance(second_it, second_end); if (first_index != second_index) { if (error_count == 0) From c8b7acc8aab81bc1c0393112849088763bfa68bb Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Sun, 12 Feb 2017 15:11:30 +0100 Subject: [PATCH 09/11] Changed lightweight_test_fail11 from run-fail to run --- test/Jamfile.v2 | 2 +- test/lightweight_test_fail11.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fb9845f..83f6012 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -78,7 +78,7 @@ run-fail lightweight_test_fail8.cpp ; run-fail lightweight_test_fail8.cpp : : : off : lightweight_test_fail8_no_rtti ; run-fail lightweight_test_fail9.cpp ; run-fail lightweight_test_fail10.cpp ; -run-fail lightweight_test_fail11.cpp ; +run lightweight_test_fail11.cpp ; run is_same_test.cpp ; diff --git a/test/lightweight_test_fail11.cpp b/test/lightweight_test_fail11.cpp index 120a859..0fb0fb9 100644 --- a/test/lightweight_test_fail11.cpp +++ b/test/lightweight_test_fail11.cpp @@ -122,5 +122,5 @@ int main() boost::report_errors(); - return boost::detail::test_errors() == test_cases; + return boost::detail::test_errors() != test_cases; } From 54e262ee135c0aa81c06f7f7f367271ca12c16ba Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Mon, 13 Feb 2017 15:55:42 +0100 Subject: [PATCH 10/11] Minor fixes --- doc/lightweight_test.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/lightweight_test.qbk b/doc/lightweight_test.qbk index c3ab7bc..77a3e49 100644 --- a/doc/lightweight_test.qbk +++ b/doc/lightweight_test.qbk @@ -128,7 +128,7 @@ Specialization of BOOST_TEST_NE which interprets expr1 and expr2 as pointers to BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) `` -Compares the content of two containers. If they have different sizes, or if any pairwise element differs, increases the error count and outputs a message containing all differing elements. +Compares the content of two sequences. If they have different sizes, or if any pairwise element differs, increases the error count and outputs a message containing at most 8 differing elements. [endsect] From 1bdb657b71ad312d7d3685f516af53f9914a1a54 Mon Sep 17 00:00:00 2001 From: Bjorn Reese Date: Mon, 13 Feb 2017 15:58:15 +0100 Subject: [PATCH 11/11] Renamed test suite for BOOST_TEST_ALL_EQ --- test/Jamfile.v2 | 2 +- ...tweight_test_fail11.cpp => lightweight_test_all_eq_test.cpp} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename test/{lightweight_test_fail11.cpp => lightweight_test_all_eq_test.cpp} (100%) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 83f6012..712de26 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -65,6 +65,7 @@ run lightweight_test_test.cpp ; run lightweight_test_test.cpp : : : off : lightweight_test_test_no_except ; run lightweight_test_test2.cpp ; +run lightweight_test_all_eq_test.cpp ; run-fail lightweight_test_fail.cpp ; run-fail lightweight_test_fail2.cpp ; @@ -78,7 +79,6 @@ run-fail lightweight_test_fail8.cpp ; run-fail lightweight_test_fail8.cpp : : : off : lightweight_test_fail8_no_rtti ; run-fail lightweight_test_fail9.cpp ; run-fail lightweight_test_fail10.cpp ; -run lightweight_test_fail11.cpp ; run is_same_test.cpp ; diff --git a/test/lightweight_test_fail11.cpp b/test/lightweight_test_all_eq_test.cpp similarity index 100% rename from test/lightweight_test_fail11.cpp rename to test/lightweight_test_all_eq_test.cpp