]>
Commit | Line | Data |
---|---|---|
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 | // Test that header file is self-contained. | |
9 | #include <beast/core/detail/get_lowest_layer.hpp> | |
10 | ||
11 | #include <beast/unit_test/suite.hpp> | |
12 | #include <type_traits> | |
13 | ||
14 | namespace beast { | |
15 | namespace detail { | |
16 | ||
17 | class get_lowest_layer_test | |
18 | : public beast::unit_test::suite | |
19 | { | |
20 | public: | |
21 | struct F1 | |
22 | { | |
23 | }; | |
24 | ||
25 | struct F2 | |
26 | { | |
27 | }; | |
28 | ||
29 | template<class F> | |
30 | struct F3 | |
31 | { | |
32 | using next_layer_type = | |
33 | typename std::remove_reference<F>::type; | |
34 | ||
35 | using lowest_layer_type = typename | |
36 | get_lowest_layer<next_layer_type>::type; | |
37 | }; | |
38 | ||
39 | template<class F> | |
40 | struct F4 | |
41 | { | |
42 | using next_layer_type = | |
43 | typename std::remove_reference<F>::type; | |
44 | ||
45 | using lowest_layer_type = typename | |
46 | get_lowest_layer<next_layer_type>::type; | |
47 | }; | |
48 | ||
49 | void | |
50 | run() | |
51 | { | |
52 | static_assert(! has_lowest_layer<F1>::value, ""); | |
53 | static_assert(! has_lowest_layer<F2>::value, ""); | |
54 | static_assert(has_lowest_layer<F3<F1>>::value, ""); | |
55 | static_assert(has_lowest_layer<F4<F3<F2>>>::value, ""); | |
56 | ||
57 | static_assert(std::is_same< | |
58 | get_lowest_layer<F1>::type, F1>::value, ""); | |
59 | ||
60 | static_assert(std::is_same< | |
61 | get_lowest_layer<F2>::type, F2>::value, ""); | |
62 | ||
63 | static_assert(std::is_same< | |
64 | get_lowest_layer<F3<F1>>::type, F1>::value, ""); | |
65 | ||
66 | static_assert(std::is_same< | |
67 | get_lowest_layer<F3<F2>>::type, F2>::value, ""); | |
68 | ||
69 | static_assert(std::is_same< | |
70 | get_lowest_layer<F4<F1>>::type, F1>::value, ""); | |
71 | ||
72 | static_assert(std::is_same< | |
73 | get_lowest_layer<F4<F2>>::type, F2>::value, ""); | |
74 | ||
75 | static_assert(std::is_same< | |
76 | get_lowest_layer<F4<F3<F1>>>::type, F1>::value, ""); | |
77 | ||
78 | static_assert(std::is_same< | |
79 | get_lowest_layer<F4<F3<F2>>>::type, F2>::value, ""); | |
80 | ||
81 | pass(); | |
82 | } | |
83 | }; | |
84 | ||
85 | BEAST_DEFINE_TESTSUITE(get_lowest_layer,core,beast); | |
86 | ||
87 | } // detail | |
88 | } // beast |