]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/beast/_experimental/unit_test/suite_list.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / beast / _experimental / unit_test / suite_list.hpp
1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9
10 #ifndef BOOST_BEAST_UNIT_TEST_SUITE_LIST_HPP
11 #define BOOST_BEAST_UNIT_TEST_SUITE_LIST_HPP
12
13 #include <boost/beast/_experimental/unit_test/suite_info.hpp>
14 #include <boost/beast/_experimental/unit_test/detail/const_container.hpp>
15 #include <boost/assert.hpp>
16 #include <boost/type_index.hpp>
17 #include <boost/functional/hash.hpp>
18 #include <typeindex>
19 #include <set>
20 #include <unordered_set>
21
22 namespace boost {
23 namespace beast {
24 namespace unit_test {
25
26 /// A container of test suites.
27 class suite_list
28 : public detail::const_container <std::set <suite_info>>
29 {
30 private:
31 #ifndef NDEBUG
32 std::unordered_set<std::string> names_;
33
34 using type_index = boost::typeindex::type_index;
35 std::unordered_set<type_index, boost::hash<type_index>> classes_;
36 #endif
37
38 public:
39 /** Insert a suite into the set.
40
41 The suite must not already exist.
42 */
43 template<class Suite>
44 void
45 insert(
46 char const* name,
47 char const* module,
48 char const* library,
49 bool manual);
50 };
51
52 //------------------------------------------------------------------------------
53
54 template<class Suite>
55 void
56 suite_list::insert(
57 char const* name,
58 char const* module,
59 char const* library,
60 bool manual)
61 {
62 #ifndef NDEBUG
63 {
64 std::string s;
65 s = std::string(library) + "." + module + "." + name;
66 auto const result(names_.insert(s));
67 BOOST_ASSERT(result.second); // Duplicate name
68 }
69
70 {
71 auto const result(classes_.insert(
72 boost::typeindex::type_id<Suite>()));
73 BOOST_ASSERT(result.second); // Duplicate type
74 }
75 #endif
76 cont().emplace(make_suite_info<Suite>(
77 name, module, library, manual));
78 }
79
80 } // unit_test
81 } // beast
82 } // boost
83
84 #endif
85