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