|
| 1 | +#include <catch.hpp> |
| 2 | +#include <zmq.hpp> |
| 3 | + |
| 4 | +#ifdef ZMQ_CPP11 |
| 5 | + |
| 6 | +namespace test_ns |
| 7 | +{ |
| 8 | +struct T_nr |
| 9 | +{ |
| 10 | +}; |
| 11 | +struct T_mr |
| 12 | +{ |
| 13 | + void *begin() const noexcept { return nullptr; } |
| 14 | + void *end() const noexcept { return nullptr; } |
| 15 | +}; |
| 16 | +struct T_fr |
| 17 | +{ |
| 18 | +}; |
| 19 | +void *begin(const T_fr &) noexcept |
| 20 | +{ |
| 21 | + return nullptr; |
| 22 | +} |
| 23 | +void *end(const T_fr &) noexcept |
| 24 | +{ |
| 25 | + return nullptr; |
| 26 | +} |
| 27 | +struct T_mfr |
| 28 | +{ |
| 29 | + void *begin() const noexcept { return nullptr; } |
| 30 | + void *end() const noexcept { return nullptr; } |
| 31 | +}; |
| 32 | +void *begin(const T_mfr &) noexcept |
| 33 | +{ |
| 34 | + return nullptr; |
| 35 | +} |
| 36 | +void *end(const T_mfr &) noexcept |
| 37 | +{ |
| 38 | + return nullptr; |
| 39 | +} |
| 40 | + |
| 41 | +// types with associated namespace std |
| 42 | +struct T_assoc_ns_nr : std::exception |
| 43 | +{ |
| 44 | +}; |
| 45 | +struct T_assoc_ns_mr : std::exception |
| 46 | +{ |
| 47 | + void *begin() const noexcept { return nullptr; } |
| 48 | + void *end() const noexcept { return nullptr; } |
| 49 | +}; |
| 50 | +struct T_assoc_ns_fr : std::exception |
| 51 | +{ |
| 52 | +}; |
| 53 | +void *begin(const T_assoc_ns_fr &) noexcept |
| 54 | +{ |
| 55 | + return nullptr; |
| 56 | +} |
| 57 | +void *end(const T_assoc_ns_fr &) noexcept |
| 58 | +{ |
| 59 | + return nullptr; |
| 60 | +} |
| 61 | +struct T_assoc_ns_mfr : std::exception |
| 62 | +{ |
| 63 | + void *begin() const noexcept { return nullptr; } |
| 64 | + void *end() const noexcept { return nullptr; } |
| 65 | +}; |
| 66 | +void *begin(const T_assoc_ns_mfr &) noexcept |
| 67 | +{ |
| 68 | + return nullptr; |
| 69 | +} |
| 70 | +void *end(const T_assoc_ns_mfr &) noexcept |
| 71 | +{ |
| 72 | + return nullptr; |
| 73 | +} |
| 74 | +} // namespace test_ns |
| 75 | + |
| 76 | +TEST_CASE("range SFINAE", "[utilities]") |
| 77 | +{ |
| 78 | + CHECK(!zmq::detail::is_range<int>::value); |
| 79 | + CHECK(zmq::detail::is_range<std::string>::value); |
| 80 | + CHECK(zmq::detail::is_range<std::string &>::value); |
| 81 | + CHECK(zmq::detail::is_range<const std::string &>::value); |
| 82 | + CHECK(zmq::detail::is_range<decltype("hello")>::value); |
| 83 | + CHECK(zmq::detail::is_range<std::initializer_list<int>>::value); |
| 84 | + |
| 85 | + CHECK(!zmq::detail::is_range<test_ns::T_nr>::value); |
| 86 | + CHECK(zmq::detail::is_range<test_ns::T_mr>::value); |
| 87 | + CHECK(zmq::detail::is_range<test_ns::T_fr>::value); |
| 88 | + CHECK(zmq::detail::is_range<test_ns::T_mfr>::value); |
| 89 | + |
| 90 | + CHECK(!zmq::detail::is_range<test_ns::T_assoc_ns_nr>::value); |
| 91 | + CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mr>::value); |
| 92 | + CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_fr>::value); |
| 93 | + CHECK(zmq::detail::is_range<test_ns::T_assoc_ns_mfr>::value); |
| 94 | +} |
| 95 | + |
| 96 | +#endif |
0 commit comments