diff --git a/test/binary_search_test.cpp b/test/binary_search_test.cpp index aeecfc0..ee4d6d2 100644 --- a/test/binary_search_test.cpp +++ b/test/binary_search_test.cpp @@ -3,18 +3,19 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +#include #include #include #include #include #include -#include +#include #include // for rand(). Would use cstdlib but VC6.4 doesn't put it in std:: #include +#include #include -#include #include -#include +#include #if defined(__SGI_STL_PORT) ? defined(__SGI_STL_OWN_IOSTREAMS) : (!defined(__GNUC__) || __GNUC__ > 2) # define USE_SSTREAM @@ -32,7 +33,7 @@ namespace { struct mystring : std::string { typedef std::string base; - + mystring(std::string const& x) : base(x) {} }; @@ -180,13 +181,13 @@ template void test_loop(Sequence& x, Compare cmp, unsigned long test_count) { typedef typename Sequence::const_iterator const_iterator; - + for (unsigned long i = 0; i < test_count; ++i) { random_sorted_sequence(x); const const_iterator start = x.begin(); const const_iterator finish = x.end(); - + unsigned key = random_number(); const const_iterator l = searches::lower_bound(start, finish, key, cmp); const const_iterator u = searches::upper_bound(start, finish, key, cmp); @@ -204,38 +205,40 @@ void test_loop(Sequence& x, Compare cmp, unsigned long test_count) if (p == u) { - assert(found_l); + BOOST_TEST(found_l); found_u = true; } unsigned value = to_int(*p); - assert(value >= last_value); + BOOST_TEST(value >= last_value); last_value = value; if (!found_l) { ++index; - assert(to_int(*p) < key); + BOOST_TEST(to_int(*p) < key); } else if (!found_u) { ++count; - assert(to_int(*p) == key); + BOOST_TEST(to_int(*p) == key); } else - assert(to_int(*p) > key); + { + BOOST_TEST(to_int(*p) > key); + } } - assert(found_l || l == finish); - assert(found_u || u == finish); + BOOST_TEST(found_l || l == finish); + BOOST_TEST(found_u || u == finish); std::pair range = searches::equal_range(start, finish, key, cmp); - assert(range.first == l); - assert(range.second == u); + BOOST_TEST(range.first == l); + BOOST_TEST(range.second == u); bool found = searches::binary_search(start, finish, key, cmp); (void)found; - assert(found == (u != l)); + BOOST_TEST(found == (u != l)); std::cout << "found " << count << " copies of " << key << " at index " << index << "\n"; } } @@ -256,5 +259,6 @@ int main() std::cout << "=== testing bidirectional iterators with compare: ===\n"; test_loop(y, cmp(), 25); std::cerr << "******TEST PASSED******\n"; - return 0; + + return boost::report_errors(); }