2021-01-02 10:34:04 +01:00
|
|
|
#include <catch2/catch.hpp>
|
2019-05-31 14:09:20 +02:00
|
|
|
#include <zmq.hpp>
|
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
#if defined(ZMQ_CPP11) && !defined(ZMQ_CPP11_PARTIAL)
|
2019-05-31 14:09:20 +02:00
|
|
|
|
|
|
|
namespace test_ns
|
|
|
|
{
|
|
|
|
struct T_nr
|
|
|
|
{
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_mr
|
|
|
|
{
|
|
|
|
void *begin() const noexcept { return nullptr; }
|
|
|
|
void *end() const noexcept { return nullptr; }
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_fr
|
|
|
|
{
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *begin(const T_fr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *end(const T_fr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_mfr
|
|
|
|
{
|
|
|
|
void *begin() const noexcept { return nullptr; }
|
|
|
|
void *end() const noexcept { return nullptr; }
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *begin(const T_mfr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *end(const T_mfr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// types with associated namespace std
|
|
|
|
struct T_assoc_ns_nr : std::exception
|
|
|
|
{
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_assoc_ns_mr : std::exception
|
|
|
|
{
|
|
|
|
void *begin() const noexcept { return nullptr; }
|
|
|
|
void *end() const noexcept { return nullptr; }
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_assoc_ns_fr : std::exception
|
|
|
|
{
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *begin(const T_assoc_ns_fr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *end(const T_assoc_ns_fr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-05-31 14:09:20 +02:00
|
|
|
struct T_assoc_ns_mfr : std::exception
|
|
|
|
{
|
|
|
|
void *begin() const noexcept { return nullptr; }
|
|
|
|
void *end() const noexcept { return nullptr; }
|
|
|
|
};
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *begin(const T_assoc_ns_mfr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
2020-01-26 10:09:20 +01:00
|
|
|
|
2019-08-31 01:14:16 +02:00
|
|
|
inline void *end(const T_assoc_ns_mfr &) noexcept
|
2019-05-31 14:09:20 +02:00
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
} // namespace test_ns
|
|
|
|
|
|
|
|
TEST_CASE("range SFINAE", "[utilities]")
|
|
|
|
{
|
|
|
|
CHECK(!zmq::detail::is_range<int>::value);
|
|
|
|
CHECK(zmq::detail::is_range<std::string>::value);
|
|
|
|
CHECK(zmq::detail::is_range<std::string &>::value);
|
|
|
|
CHECK(zmq::detail::is_range<const std::string &>::value);
|
|
|
|
CHECK(zmq::detail::is_range<decltype("hello")>::value);
|
|
|
|
CHECK(zmq::detail::is_range<std::initializer_list<int>>::value);
|
|
|
|
|
|
|
|
CHECK(!zmq::detail::is_range<test_ns::T_nr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_mr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_fr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_mfr>::value);
|
|
|
|
|
|
|
|
CHECK(!zmq::detail::is_range<test_ns::T_assoc_ns_nr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_fr>::value);
|
|
|
|
CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mfr>::value);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|