]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/utility/test/string_ref_test2.cpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / libs / utility / test / string_ref_test2.cpp
index 081af54a5bb5c7095086a4ea1e9e006407b16b3c..ccb5d6dae119a9b0dbde98f487318bfe1a47ea19 100644 (file)
@@ -12,8 +12,7 @@
 
 #include <boost/utility/string_ref.hpp>
 
-#define BOOST_TEST_MAIN
-#include <boost/test/unit_test.hpp>
+#include <boost/core/lightweight_test.hpp>
 
 typedef boost::string_ref string_ref;
 
@@ -24,27 +23,27 @@ void ends_with ( const char *arg ) {
     const char *p = arg;
 
     while ( *p ) {
-        BOOST_CHECK ( sr.ends_with ( p ));
+        BOOST_TEST ( sr.ends_with ( p ));
         ++p;
         }
 
     while ( !sr2.empty ()) {
-        BOOST_CHECK ( sr.ends_with ( sr2 ));
+        BOOST_TEST ( sr.ends_with ( sr2 ));
         sr2.remove_prefix (1);
         }
 
     sr2 = arg;
     while ( !sr2.empty ()) {
-        BOOST_CHECK ( sr.ends_with ( sr2 ));
+        BOOST_TEST ( sr.ends_with ( sr2 ));
         sr2.remove_prefix (1);
         }
 
     char ch = sz == 0 ? '\0' : arg [ sz - 1 ];
     sr2 = arg;
     if ( sz > 0 )
-      BOOST_CHECK ( sr2.ends_with ( ch ));
-    BOOST_CHECK ( !sr2.ends_with ( ++ch ));
-    BOOST_CHECK ( sr2.ends_with ( string_ref ()));
+      BOOST_TEST ( sr2.ends_with ( ch ));
+    BOOST_TEST ( !sr2.ends_with ( ++ch ));
+    BOOST_TEST ( sr2.ends_with ( string_ref ()));
     }
 
 void starts_with ( const char *arg ) {
@@ -54,21 +53,21 @@ void starts_with ( const char *arg ) {
     const char *p = arg + std::strlen ( arg ) - 1;
     while ( p >= arg ) {
         std::string foo ( arg, p + 1 );
-        BOOST_CHECK ( sr.starts_with ( foo ));
+        BOOST_TEST ( sr.starts_with ( foo ));
         --p;
         }
 
     while ( !sr2.empty ()) {
-        BOOST_CHECK ( sr.starts_with ( sr2 ));
+        BOOST_TEST ( sr.starts_with ( sr2 ));
         sr2.remove_suffix (1);
         }
 
     char ch = *arg;
     sr2 = arg;
   if ( sz > 0 )
-    BOOST_CHECK ( sr2.starts_with ( ch ));
-    BOOST_CHECK ( !sr2.starts_with ( ++ch ));
-    BOOST_CHECK ( sr2.starts_with ( string_ref ()));
+    BOOST_TEST ( sr2.starts_with ( ch ));
+    BOOST_TEST ( !sr2.starts_with ( ++ch ));
+    BOOST_TEST ( sr2.starts_with ( string_ref ()));
     }
 
 void reverse ( const char *arg ) {
@@ -78,14 +77,14 @@ void reverse ( const char *arg ) {
     string_ref sr2 ( string1 );
     std::string string2 ( sr2.rbegin (), sr2.rend ());
 
-    BOOST_CHECK ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
-    BOOST_CHECK ( string2 == arg );
-    BOOST_CHECK ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
+    BOOST_TEST ( std::equal ( sr2.rbegin (), sr2.rend (), arg ));
+    BOOST_TEST ( string2 == arg );
+    BOOST_TEST ( std::equal ( sr1.begin (), sr1.end (), string2.begin ()));
     }
 
 // This helper function eliminates signed vs. unsigned warnings
 string_ref::size_type ptr_diff ( const char *res, const char *base ) {
-    BOOST_CHECK ( res >= base );
+    BOOST_TEST ( res >= base );
     return static_cast<string_ref::size_type> ( res - base );
     }
 
@@ -99,7 +98,7 @@ void find ( const char *arg ) {
     sr1 = arg;
     while ( *p ) {
       string_ref::size_type pos = sr1.find(*p);
-      BOOST_CHECK ( pos != string_ref::npos && ( pos <= ptr_diff ( p, arg )));
+      BOOST_TEST ( pos != string_ref::npos && ( pos <= ptr_diff ( p, arg )));
       ++p;
       }
 
@@ -108,7 +107,7 @@ void find ( const char *arg ) {
     sr1 = arg;
     while ( *p ) {
       string_ref::size_type pos = sr1.rfind(*p);
-      BOOST_CHECK ( pos != string_ref::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
+      BOOST_TEST ( pos != string_ref::npos && pos < sr1.size () && ( pos >= ptr_diff ( p, arg )));
       ++p;
       }
 
@@ -118,7 +117,7 @@ void find ( const char *arg ) {
     while ( *p && *(p+1)) {
         string_ref sr3 ( p, 2 );
         string_ref::size_type pos = sr1.find ( sr3 );
-        BOOST_CHECK ( pos != string_ref::npos && pos <= static_cast<string_ref::size_type>( p - arg ));
+        BOOST_TEST ( pos != string_ref::npos && pos <= static_cast<string_ref::size_type>( p - arg ));
         p++;
         }
 
@@ -129,9 +128,9 @@ void find ( const char *arg ) {
     for ( int ch = 1; ch < 256; ++ch ) {
         string_ref::size_type pos = sr1.find(ch);
         const char *strp = std::strchr ( arg, ch );
-        BOOST_CHECK (( strp == NULL ) == ( pos == string_ref::npos ));
+        BOOST_TEST (( strp == NULL ) == ( pos == string_ref::npos ));
         if ( strp != NULL )
-            BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
+            BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
     }
 
     sr1 = arg;
@@ -141,9 +140,9 @@ void find ( const char *arg ) {
     for ( int ch = 1; ch < 256; ++ch ) {
         string_ref::size_type pos = sr1.rfind(ch);
         const char *strp = std::strrchr ( arg, ch );
-        BOOST_CHECK (( strp == NULL ) == ( pos == string_ref::npos ));
+        BOOST_TEST (( strp == NULL ) == ( pos == string_ref::npos ));
         if ( strp != NULL )
-            BOOST_CHECK ( ptr_diff ( strp, arg ) == pos );
+            BOOST_TEST ( ptr_diff ( strp, arg ) == pos );
     }
 
 
@@ -152,7 +151,7 @@ void find ( const char *arg ) {
     sr1 = arg;
     while ( !sr1.empty ()) {
         string_ref::size_type pos = sr1.find(*p);
-        BOOST_CHECK ( pos == 0 );
+        BOOST_TEST ( pos == 0 );
         sr1.remove_prefix (1);
         ++p;
         }
@@ -162,7 +161,7 @@ void find ( const char *arg ) {
     p    = arg + std::strlen ( arg ) - 1;
     while ( !sr1.empty ()) {
         string_ref::size_type pos = sr1.rfind(*p);
-        BOOST_CHECK ( pos == sr1.size () - 1 );
+        BOOST_TEST ( pos == sr1.size () - 1 );
         sr1.remove_suffix (1);
         --p;
         }
@@ -172,7 +171,7 @@ void find ( const char *arg ) {
     p    = arg;
     while ( !sr1.empty ()) {
         string_ref::size_type pos = sr1.find_first_of(*p);
-        BOOST_CHECK ( pos == 0 );
+        BOOST_TEST ( pos == 0 );
         sr1.remove_prefix (1);
         ++p;
         }
@@ -183,7 +182,7 @@ void find ( const char *arg ) {
     p    = arg + std::strlen ( arg ) - 1;
     while ( !sr1.empty ()) {
         string_ref::size_type pos = sr1.find_last_of(*p);
-        BOOST_CHECK ( pos == sr1.size () - 1 );
+        BOOST_TEST ( pos == sr1.size () - 1 );
         sr1.remove_suffix (1);
         --p;
         }
@@ -192,8 +191,8 @@ void find ( const char *arg ) {
     sr1 = arg;
     sr2 = arg;
     while ( !sr1.empty() ) {
-        BOOST_CHECK ( sr1.find_first_of ( sr2 )     == 0 );
-        BOOST_CHECK ( sr1.find_first_not_of ( sr2 ) == string_ref::npos );
+        BOOST_TEST ( sr1.find_first_of ( sr2 )     == 0 );
+        BOOST_TEST ( sr1.find_first_not_of ( sr2 ) == string_ref::npos );
         sr1.remove_prefix ( 1 );
         }
 
@@ -202,14 +201,14 @@ void find ( const char *arg ) {
     while ( *p ) {
         string_ref::size_type pos1 = sr1.find_first_of(*p);
         string_ref::size_type pos2 = sr1.find_first_not_of(*p);
-        BOOST_CHECK ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
+        BOOST_TEST ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 <= ptr_diff ( p, arg ));
         if ( pos2 != string_ref::npos ) {
             for ( size_t i = 0 ; i < pos2; ++i )
-                BOOST_CHECK ( sr1[i] == *p );
-            BOOST_CHECK ( sr1 [ pos2 ] != *p );
+                BOOST_TEST ( sr1[i] == *p );
+            BOOST_TEST ( sr1 [ pos2 ] != *p );
             }
 
-        BOOST_CHECK ( pos2 != pos1 );
+        BOOST_TEST ( pos2 != pos1 );
         ++p;
         }
 
@@ -217,8 +216,8 @@ void find ( const char *arg ) {
     sr1 = arg;
     sr2 = arg;
     while ( !sr1.empty() ) {
-        BOOST_CHECK ( sr1.find_last_of ( sr2 )     == ( sr1.size () - 1 ));
-        BOOST_CHECK ( sr1.find_last_not_of ( sr2 ) == string_ref::npos );
+        BOOST_TEST ( sr1.find_last_of ( sr2 )     == ( sr1.size () - 1 ));
+        BOOST_TEST ( sr1.find_last_not_of ( sr2 ) == string_ref::npos );
         sr1.remove_suffix ( 1 );
         }
 
@@ -227,15 +226,15 @@ void find ( const char *arg ) {
     while ( *p ) {
         string_ref::size_type pos1 = sr1.find_last_of(*p);
         string_ref::size_type pos2 = sr1.find_last_not_of(*p);
-        BOOST_CHECK ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
-        BOOST_CHECK ( pos2 == string_ref::npos || pos1 < sr1.size ());
+        BOOST_TEST ( pos1 != string_ref::npos && pos1 < sr1.size () && pos1 >= ptr_diff ( p, arg ));
+        BOOST_TEST ( pos2 == string_ref::npos || pos1 < sr1.size ());
         if ( pos2 != string_ref::npos ) {
             for ( size_t i = sr1.size () -1 ; i > pos2; --i )
-                BOOST_CHECK ( sr1[i] == *p );
-            BOOST_CHECK ( sr1 [ pos2 ] != *p );
+                BOOST_TEST ( sr1[i] == *p );
+            BOOST_TEST ( sr1 [ pos2 ] != *p );
             }
 
-        BOOST_CHECK ( pos2 != pos1 );
+        BOOST_TEST ( pos2 != pos1 );
         ++p;
         }
 
@@ -251,11 +250,11 @@ void to_string ( const char *arg ) {
     sr1 = arg;
 // str2 = sr1.to_string<std::allocator<char> > ();
     str2 = sr1.to_string ();
-    BOOST_CHECK ( str1 == str2 );
+    BOOST_TEST ( str1 == str2 );
 
 #ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
     std::string str3 = static_cast<std::string> ( sr1 );
-    BOOST_CHECK ( str1 == str3 );
+    BOOST_TEST ( str1 == str3 );
 #endif
     }
 
@@ -266,28 +265,28 @@ void compare ( const char *arg ) {
 
     str1.assign ( arg );
     sr1 = arg;
-    BOOST_CHECK ( sr1  == sr1);     // compare string_ref and string_ref
-    BOOST_CHECK ( sr1  == str1);    // compare string and string_ref
-    BOOST_CHECK ( str1 == sr1 );    // compare string_ref and string
-    BOOST_CHECK ( sr1  == arg );    // compare string_ref and pointer
-    BOOST_CHECK ( arg  == sr1 );    // compare pointer and string_ref
+    BOOST_TEST ( sr1  == sr1);     // compare string_ref and string_ref
+    BOOST_TEST ( sr1  == str1);    // compare string and string_ref
+    BOOST_TEST ( str1 == sr1 );    // compare string_ref and string
+    BOOST_TEST ( sr1  == arg );    // compare string_ref and pointer
+    BOOST_TEST ( arg  == sr1 );    // compare pointer and string_ref
 
     if ( sr1.size () > 0 ) {
         (*str1.rbegin())++;
-        BOOST_CHECK ( sr1  != str1 );
-        BOOST_CHECK ( str1 != sr1 );
-        BOOST_CHECK ( sr1 < str1 );
-        BOOST_CHECK ( sr1 <= str1 );
-        BOOST_CHECK ( str1 > sr1 );
-        BOOST_CHECK ( str1 >= sr1 );
+        BOOST_TEST ( sr1  != str1 );
+        BOOST_TEST ( str1 != sr1 );
+        BOOST_TEST ( sr1 < str1 );
+        BOOST_TEST ( sr1 <= str1 );
+        BOOST_TEST ( str1 > sr1 );
+        BOOST_TEST ( str1 >= sr1 );
 
         (*str1.rbegin()) -= 2;
-        BOOST_CHECK ( sr1  != str1 );
-        BOOST_CHECK ( str1 != sr1 );
-        BOOST_CHECK ( sr1 > str1 );
-        BOOST_CHECK ( sr1 >= str1 );
-        BOOST_CHECK ( str1 < sr1 );
-        BOOST_CHECK ( str1 <= sr1 );
+        BOOST_TEST ( sr1  != str1 );
+        BOOST_TEST ( str1 != sr1 );
+        BOOST_TEST ( sr1 > str1 );
+        BOOST_TEST ( sr1 >= str1 );
+        BOOST_TEST ( str1 < sr1 );
+        BOOST_TEST ( str1 <= sr1 );
         }
     }
 
@@ -301,7 +300,7 @@ const char *test_strings [] = {
     NULL
     };
 
-BOOST_AUTO_TEST_CASE( test_main )
+int main()
 {
     const char **p = &test_strings[0];
 
@@ -315,4 +314,6 @@ BOOST_AUTO_TEST_CASE( test_main )
 
         p++;
         }
+
+    return boost::report_errors();
 }