mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 05:44:38 +02:00
Simplify get_lowest_layer test
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* Refactor static_string
|
||||
* Refactor base64
|
||||
* Use static_string for WebSocket handshakes
|
||||
* Simplify get_lowest_layer test
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -8,81 +8,67 @@
|
||||
// Test that header file is self-contained.
|
||||
#include <beast/core/detail/get_lowest_layer.hpp>
|
||||
|
||||
#include <beast/unit_test/suite.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace beast {
|
||||
namespace detail {
|
||||
|
||||
class get_lowest_layer_test
|
||||
: public beast::unit_test::suite
|
||||
struct F1
|
||||
{
|
||||
public:
|
||||
struct F1
|
||||
{
|
||||
};
|
||||
|
||||
struct F2
|
||||
{
|
||||
};
|
||||
|
||||
template<class F>
|
||||
struct F3
|
||||
{
|
||||
using next_layer_type =
|
||||
typename std::remove_reference<F>::type;
|
||||
|
||||
using lowest_layer_type = typename
|
||||
get_lowest_layer<next_layer_type>::type;
|
||||
};
|
||||
|
||||
template<class F>
|
||||
struct F4
|
||||
{
|
||||
using next_layer_type =
|
||||
typename std::remove_reference<F>::type;
|
||||
|
||||
using lowest_layer_type = typename
|
||||
get_lowest_layer<next_layer_type>::type;
|
||||
};
|
||||
|
||||
void
|
||||
run()
|
||||
{
|
||||
static_assert(! has_lowest_layer<F1>::value, "");
|
||||
static_assert(! has_lowest_layer<F2>::value, "");
|
||||
static_assert(has_lowest_layer<F3<F1>>::value, "");
|
||||
static_assert(has_lowest_layer<F4<F3<F2>>>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F1>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F2>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F3<F1>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F3<F2>>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F1>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F2>>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F3<F1>>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F3<F2>>>::type, F2>::value, "");
|
||||
|
||||
pass();
|
||||
}
|
||||
};
|
||||
|
||||
BEAST_DEFINE_TESTSUITE(get_lowest_layer,core,beast);
|
||||
struct F2
|
||||
{
|
||||
};
|
||||
|
||||
template<class F>
|
||||
struct F3
|
||||
{
|
||||
using next_layer_type =
|
||||
typename std::remove_reference<F>::type;
|
||||
|
||||
using lowest_layer_type = typename
|
||||
get_lowest_layer<next_layer_type>::type;
|
||||
};
|
||||
|
||||
template<class F>
|
||||
struct F4
|
||||
{
|
||||
using next_layer_type =
|
||||
typename std::remove_reference<F>::type;
|
||||
|
||||
using lowest_layer_type = typename
|
||||
get_lowest_layer<next_layer_type>::type;
|
||||
};
|
||||
|
||||
static_assert(! has_lowest_layer<F1>::value, "");
|
||||
static_assert(! has_lowest_layer<F2>::value, "");
|
||||
static_assert(has_lowest_layer<F3<F1>>::value, "");
|
||||
static_assert(has_lowest_layer<F4<F3<F2>>>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F1>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F2>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F3<F1>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F3<F2>>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F1>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F2>>::type, F2>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F3<F1>>>::type, F1>::value, "");
|
||||
|
||||
static_assert(std::is_same<
|
||||
get_lowest_layer<F4<F3<F2>>>::type, F2>::value, "");
|
||||
|
||||
} // detail
|
||||
} // beast
|
||||
|
Reference in New Issue
Block a user