]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/leaf/test/diagnostic_info_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / leaf / test / diagnostic_info_test.cpp
index 42cc1492d6fe188be2566edb13d7d3fe940bde97..cbc9afe0c3b19caf16ddacd7dd18be38400e8d15 100644 (file)
@@ -1,17 +1,27 @@
-// Copyright (c) 2018-2020 Emil Dotchevski and Reverge Studios, Inc.
+// Copyright 2018-2022 Emil Dotchevski and Reverge Studios, Inc.
 
 // 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 <boost/leaf/detail/config.hpp>
-#include <boost/leaf/handle_errors.hpp>
-#include <boost/leaf/result.hpp>
-#include <boost/leaf/common.hpp>
+#ifdef BOOST_LEAF_TEST_SINGLE_HEADER
+#   include "leaf.hpp"
+#else
+#   include <boost/leaf/config.hpp>
+#   include <boost/leaf/handle_errors.hpp>
+#   include <boost/leaf/result.hpp>
+#   include <boost/leaf/common.hpp>
+#endif
+
 #include "lightweight_test.hpp"
 #include <sstream>
 
 namespace leaf = boost::leaf;
 
+enum class enum_class_payload
+{
+    value
+};
+
 template <int A>
 struct unexpected_test
 {
@@ -81,6 +91,7 @@ int main()
                 non_printable_info_non_printable_payload(),
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
+                enum_class_payload{},
                 leaf::e_errno{ENOENT} );
         },
         [](
@@ -89,14 +100,17 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::error_info const & unmatched )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << unmatched;
             std::string s = st.str();
             BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos);
             std::cout << s;
+#endif
         },
         []()
         {
@@ -115,6 +129,7 @@ int main()
                 non_printable_info_non_printable_payload(),
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
+                enum_class_payload{},
                 leaf::e_errno{ENOENT} );
         },
         [](
@@ -123,27 +138,31 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::diagnostic_info const & unmatched )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << unmatched;
             std::string s = st.str();
-#if BOOST_LEAF_DIAGNOSTICS
+#if BOOST_LEAF_CFG_DIAGNOSTICS
             BOOST_TEST_NE(s.find("leaf::diagnostic_info for Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("e_source_location"), s.npos);
             BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos);
             BOOST_TEST_NE(s.find(": {Non-Printable}"), s.npos);
+            BOOST_TEST_NE(s.find("enum_class_payload"), s.npos);
             BOOST_TEST_NE(s.find("Detected 2 attempts"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos);
             BOOST_TEST_EQ(s.find("unexpected_test<2>"), s.npos);
 #else
-            BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_DIAGNOSTICS 1"), s.npos);
+            BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos);
             BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos);
 #endif
             std::cout << s;
+#endif
         },
         []()
         {
@@ -162,6 +181,7 @@ int main()
                 non_printable_info_non_printable_payload(),
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
+                enum_class_payload{},
                 leaf::e_errno{ENOENT} );
         },
         [](
@@ -170,41 +190,45 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::verbose_diagnostic_info const & di )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << di;
             std::string s = st.str();
-#if BOOST_LEAF_DIAGNOSTICS
+#if BOOST_LEAF_CFG_DIAGNOSTICS
             BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info for Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("e_source_location"), s.npos);
             BOOST_TEST_NE(s.find("*** printable_info_printable_payload printed printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos);
             BOOST_TEST_NE(s.find(": {Non-Printable}"), s.npos);
+            BOOST_TEST_NE(s.find("enum_class"), s.npos);
             BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos);
             BOOST_TEST_NE(s.find(": 1"), s.npos);
             BOOST_TEST_NE(s.find(": 2"), s.npos);
 #else
-            BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_DIAGNOSTICS 1"), s.npos);
+            BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos);
             BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos);
 #endif
             std::cout << s;
+#endif
         },
         []()
         {
             BOOST_ERROR("Bad error dispatch");
         } );
 
-    std::cout << __LINE__  << " ----\n";
-
     ///////////////////////////////////
 
 #ifndef BOOST_LEAF_NO_EXCEPTIONS
 
+    std::cout << __LINE__  << " ----\n";
+
     leaf::try_catch(
         []
         {
@@ -215,6 +239,7 @@ int main()
                 non_printable_info_non_printable_payload(),
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
+                enum_class_payload{},
                 leaf::e_errno{ENOENT} );
         },
         [](
@@ -223,9 +248,11 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::error_info const & unmatched )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << unmatched;
             std::string s = st.str();
@@ -233,6 +260,7 @@ int main()
             BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos);
             BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos);
             std::cout << s;
+#endif
         } );
 
     std::cout << __LINE__  << " ----\n";
@@ -245,6 +273,7 @@ int main()
                 printable_info_non_printable_payload(),
                 non_printable_info_printable_payload(),
                 non_printable_info_non_printable_payload(),
+                enum_class_payload{},
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
                 leaf::e_errno{ENOENT} );
@@ -255,13 +284,15 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::diagnostic_info const & unmatched )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << unmatched;
             std::string s = st.str();
-#if BOOST_LEAF_DIAGNOSTICS
+#if BOOST_LEAF_CFG_DIAGNOSTICS
             BOOST_TEST_NE(s.find("leaf::diagnostic_info for Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos);
             BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos);
@@ -270,16 +301,18 @@ int main()
             BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos);
             BOOST_TEST_NE(s.find(": {Non-Printable}"), s.npos);
+            BOOST_TEST_NE(s.find("enum_class_payload"), s.npos);
             BOOST_TEST_NE(s.find("Detected 2 attempts"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos);
             BOOST_TEST_EQ(s.find("unexpected_test<2>"), s.npos);
 #else
-            BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_DIAGNOSTICS 1"), s.npos);
+            BOOST_TEST_NE(s.find("leaf::diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos);
             BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos);
             BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos);
 #endif
             std::cout << s;
+#endif
         } );
 
     std::cout << __LINE__  << " ----\n";
@@ -292,6 +325,7 @@ int main()
                 printable_info_non_printable_payload(),
                 non_printable_info_printable_payload(),
                 non_printable_info_non_printable_payload(),
+                enum_class_payload{},
                 unexpected_test<1>{1},
                 unexpected_test<2>{2},
                 leaf::e_errno{ENOENT} );
@@ -302,13 +336,15 @@ int main()
             printable_info_non_printable_payload,
             non_printable_info_printable_payload,
             non_printable_info_non_printable_payload,
+            enum_class_payload,
             leaf::e_errno,
             leaf::verbose_diagnostic_info const & di )
         {
+#if BOOST_LEAF_CFG_STD_STRING
             std::ostringstream st;
             st << di;
             std::string s = st.str();
-#if BOOST_LEAF_DIAGNOSTICS
+#if BOOST_LEAF_CFG_DIAGNOSTICS
             BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info for Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos);
             BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos);
@@ -317,18 +353,20 @@ int main()
             BOOST_TEST_NE(s.find("*** printable_info_non_printable_payload ***"), s.npos);
             BOOST_TEST_NE(s.find(": printed printable_payload"), s.npos);
             BOOST_TEST_NE(s.find(": {Non-Printable}"), s.npos);
+            BOOST_TEST_NE(s.find("enum_class_payload"), s.npos);
             BOOST_TEST_NE(s.find("Unhandled error objects:"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<1>"), s.npos);
             BOOST_TEST_NE(s.find("unexpected_test<2>"), s.npos);
             BOOST_TEST_NE(s.find(": 1"), s.npos);
             BOOST_TEST_NE(s.find(": 2"), s.npos);
 #else
-            BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_DIAGNOSTICS 1"), s.npos);
+            BOOST_TEST_NE(s.find("leaf::verbose_diagnostic_info requires #define BOOST_LEAF_CFG_DIAGNOSTICS 1"), s.npos);
             BOOST_TEST_NE(s.find("leaf::error_info: Error ID = "), s.npos);
             BOOST_TEST_NE(s.find("Exception dynamic type: "), s.npos);
             BOOST_TEST_NE(s.find("std::exception::what(): my_exception"), s.npos);
 #endif
             std::cout << s;
+#endif
         } );
 
 #endif