mirror of
https://github.com/boostorg/core.git
synced 2025-07-30 04:47:24 +02:00
Fixed error output of test_all_eq_impl
This commit is contained in:
@ -189,13 +189,13 @@ void test_all_eq_impl(FormattedOutputFunction& output,
|
|||||||
{
|
{
|
||||||
if (std::distance(first_begin, first_end) != std::distance(second_begin, 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);
|
::boost::detail::error_impl("Container sizes are different", file, line, function);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ForwardIterator1 first_it = first_begin;
|
ForwardIterator1 first_it = first_begin;
|
||||||
ForwardIterator2 second_it = second_begin;
|
ForwardIterator2 second_it = second_begin;
|
||||||
bool first_iteration = true;
|
std::size_t error_count = 0;
|
||||||
do
|
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))
|
||||||
@ -205,20 +205,27 @@ void test_all_eq_impl(FormattedOutputFunction& output,
|
|||||||
}
|
}
|
||||||
if (first_it == first_end)
|
if (first_it == first_end)
|
||||||
{
|
{
|
||||||
boost::detail::report_errors_remind();
|
break; // do-while
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (first_iteration)
|
if (error_count == 0)
|
||||||
{
|
{
|
||||||
first_iteration = true;
|
|
||||||
output << file << "(" << line << "): Container contents differ in function '" << function << "': mismatching indices";
|
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) << "] '" << *first_it << "' != '" << *second_it << "'";
|
||||||
++first_it;
|
++first_it;
|
||||||
++second_it;
|
++second_it;
|
||||||
|
++error_count;
|
||||||
} while (first_it != first_end);
|
} 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ run-fail lightweight_test_fail8.cpp ;
|
|||||||
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
|
run-fail lightweight_test_fail8.cpp : : : <rtti>off : lightweight_test_fail8_no_rtti ;
|
||||||
run-fail lightweight_test_fail9.cpp ;
|
run-fail lightweight_test_fail9.cpp ;
|
||||||
run-fail lightweight_test_fail10.cpp ;
|
run-fail lightweight_test_fail10.cpp ;
|
||||||
|
run-fail lightweight_test_fail11.cpp ;
|
||||||
|
|
||||||
run is_same_test.cpp ;
|
run is_same_test.cpp ;
|
||||||
|
|
||||||
|
50
test/lightweight_test_fail11.cpp
Normal file
50
test/lightweight_test_fail11.cpp
Normal file
@ -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 <vector>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
int test_cases = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<int> x, y;
|
||||||
|
x.push_back( 1 );
|
||||||
|
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
|
||||||
|
++test_cases;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::vector<int> x, y;
|
||||||
|
y.push_back( 1 );
|
||||||
|
BOOST_TEST_ALL_EQ( x.begin(), x.end(), y.begin(), y.end() );
|
||||||
|
++test_cases;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::vector<int> 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<float> 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;
|
||||||
|
}
|
Reference in New Issue
Block a user