]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/detail/test/binary_search_test.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / detail / test / binary_search_test.cpp
index aeecfc0888cfcd58da413b1ba5e9ff28333c62f9..ee4d6d2fa97af64c353306ab6f7e4f81d75ff3a5 100644 (file)
@@ -3,18 +3,19 @@
 // accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
+#include <boost/detail/binary_search.hpp>
 #include <vector>
 #include <string>
 #include <memory>
 #include <climits>
 #include <iostream>
-#include <cassert>
+#include <cstddef>
 #include <stdlib.h> // for rand(). Would use cstdlib but VC6.4 doesn't put it in std::
 #include <list>
+#include <utility>
 #include <algorithm>
-#include <boost/detail/binary_search.hpp>
 #include <boost/detail/workaround.hpp>
-#include <cstddef>
+#include <boost/core/lightweight_test.hpp>
 
 #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 <class Sequence, class Compare>
 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<Compare>::lower_bound(start, finish, key, cmp);
         const const_iterator u = searches<Compare>::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<const_iterator, const_iterator>
             range = searches<Compare>::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<Compare>::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();
 }