]> git.proxmox.com Git - ceph.git/blame - ceph/src/Beast/extras/beast/unit_test/suite_list.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / Beast / extras / beast / unit_test / suite_list.hpp
CommitLineData
7c673cae
FG
1//
2// Copyright (c) 2013-2017 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
8#ifndef BEAST_UNIT_TEST_SUITE_LIST_HPP
9#define BEAST_UNIT_TEST_SUITE_LIST_HPP
10
11#include <beast/unit_test/suite_info.hpp>
12#include <beast/unit_test/detail/const_container.hpp>
13#include <boost/assert.hpp>
14#include <typeindex>
15#include <set>
16#include <unordered_set>
17
18namespace beast {
19namespace unit_test {
20
21/// A container of test suites.
22class suite_list
23 : public detail::const_container <std::set <suite_info>>
24{
25private:
26#ifndef NDEBUG
27 std::unordered_set<std::string> names_;
28 std::unordered_set<std::type_index> classes_;
29#endif
30
31public:
32 /** Insert a suite into the set.
33
34 The suite must not already exist.
35 */
36 template<class Suite>
37 void
38 insert(
39 char const* name,
40 char const* module,
41 char const* library,
42 bool manual);
43};
44
45//------------------------------------------------------------------------------
46
47template<class Suite>
48void
49suite_list::insert(
50 char const* name,
51 char const* module,
52 char const* library,
53 bool manual)
54{
55#ifndef NDEBUG
56 {
57 std::string s;
58 s = std::string(library) + "." + module + "." + name;
59 auto const result(names_.insert(s));
60 BOOST_ASSERT(result.second); // Duplicate name
61 }
62
63 {
64 auto const result(classes_.insert(
65 std::type_index(typeid(Suite))));
66 BOOST_ASSERT(result.second); // Duplicate type
67 }
68#endif
69 cont().emplace(make_suite_info<Suite>(
70 name, module, library, manual));
71}
72
73} // unit_test
74} // beast
75
76#endif
77