| 1 | /* |
| 2 | Copyright 2019 Glen Joseph Fernandes |
| 3 | (glenjofe@gmail.com) |
| 4 | |
| 5 | Distributed under the Boost Software License, Version 1.0. |
| 6 | (http://www.boost.org/LICENSE_1_0.txt) |
| 7 | */ |
| 8 | #include <boost/config.hpp> |
| 9 | #if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE) |
| 10 | #include <boost/core/span.hpp> |
| 11 | #include <boost/core/lightweight_test_trait.hpp> |
| 12 | |
| 13 | void test_element_type() |
| 14 | { |
| 15 | BOOST_TEST_TRAIT_SAME(int, |
| 16 | boost::span<int>::element_type); |
| 17 | BOOST_TEST_TRAIT_SAME(char, |
| 18 | boost::span<char>::element_type); |
| 19 | } |
| 20 | |
| 21 | void test_value_type() |
| 22 | { |
| 23 | BOOST_TEST_TRAIT_SAME(char, |
| 24 | boost::span<char>::value_type); |
| 25 | BOOST_TEST_TRAIT_SAME(int, |
| 26 | boost::span<int>::value_type); |
| 27 | BOOST_TEST_TRAIT_SAME(int, |
| 28 | boost::span<const int>::value_type); |
| 29 | BOOST_TEST_TRAIT_SAME(int, |
| 30 | boost::span<volatile int>::value_type); |
| 31 | BOOST_TEST_TRAIT_SAME(int, |
| 32 | boost::span<const volatile int>::value_type); |
| 33 | } |
| 34 | |
| 35 | void test_size_type() |
| 36 | { |
| 37 | BOOST_TEST_TRAIT_SAME(std::size_t, |
| 38 | boost::span<char>::size_type); |
| 39 | BOOST_TEST_TRAIT_SAME(std::size_t, |
| 40 | boost::span<int>::size_type); |
| 41 | } |
| 42 | |
| 43 | void test_difference_type() |
| 44 | { |
| 45 | BOOST_TEST_TRAIT_SAME(std::ptrdiff_t, |
| 46 | boost::span<char>::difference_type); |
| 47 | BOOST_TEST_TRAIT_SAME(std::ptrdiff_t, |
| 48 | boost::span<int>::difference_type); |
| 49 | } |
| 50 | |
| 51 | void test_pointer() |
| 52 | { |
| 53 | BOOST_TEST_TRAIT_SAME(char*, |
| 54 | boost::span<char>::pointer); |
| 55 | BOOST_TEST_TRAIT_SAME(int*, |
| 56 | boost::span<int>::pointer); |
| 57 | } |
| 58 | |
| 59 | void test_const_pointer() |
| 60 | { |
| 61 | BOOST_TEST_TRAIT_SAME(const char*, |
| 62 | boost::span<char>::const_pointer); |
| 63 | BOOST_TEST_TRAIT_SAME(const int*, |
| 64 | boost::span<int>::const_pointer); |
| 65 | } |
| 66 | |
| 67 | void test_reference() |
| 68 | { |
| 69 | BOOST_TEST_TRAIT_SAME(char&, |
| 70 | boost::span<char>::reference); |
| 71 | BOOST_TEST_TRAIT_SAME(int&, |
| 72 | boost::span<int>::reference); |
| 73 | } |
| 74 | |
| 75 | void test_const_reference() |
| 76 | { |
| 77 | BOOST_TEST_TRAIT_SAME(const char&, |
| 78 | boost::span<char>::const_reference); |
| 79 | BOOST_TEST_TRAIT_SAME(const int&, |
| 80 | boost::span<int>::const_reference); |
| 81 | } |
| 82 | |
| 83 | void test_iterator() |
| 84 | { |
| 85 | BOOST_TEST_TRAIT_SAME(char*, |
| 86 | boost::span<char>::iterator); |
| 87 | BOOST_TEST_TRAIT_SAME(int*, |
| 88 | boost::span<int>::iterator); |
| 89 | } |
| 90 | |
| 91 | void test_const_iterator() |
| 92 | { |
| 93 | BOOST_TEST_TRAIT_SAME(const char*, |
| 94 | boost::span<char>::const_iterator); |
| 95 | BOOST_TEST_TRAIT_SAME(const int*, |
| 96 | boost::span<int>::const_iterator); |
| 97 | } |
| 98 | |
| 99 | void test_reverse_iterator() |
| 100 | { |
| 101 | BOOST_TEST_TRAIT_SAME(std::reverse_iterator<char*>, |
| 102 | boost::span<char>::reverse_iterator); |
| 103 | BOOST_TEST_TRAIT_SAME(std::reverse_iterator<int*>, |
| 104 | boost::span<int>::reverse_iterator); |
| 105 | } |
| 106 | |
| 107 | void test_const_reverse_iterator() |
| 108 | { |
| 109 | BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const char*>, |
| 110 | boost::span<char>::const_reverse_iterator); |
| 111 | BOOST_TEST_TRAIT_SAME(std::reverse_iterator<const int*>, |
| 112 | boost::span<int>::const_reverse_iterator); |
| 113 | } |
| 114 | |
| 115 | int main() |
| 116 | { |
| 117 | test_element_type(); |
| 118 | test_value_type(); |
| 119 | test_size_type(); |
| 120 | test_difference_type(); |
| 121 | test_pointer(); |
| 122 | test_const_pointer(); |
| 123 | test_reference(); |
| 124 | test_const_reference(); |
| 125 | test_iterator(); |
| 126 | test_const_iterator(); |
| 127 | test_reverse_iterator(); |
| 128 | test_const_reverse_iterator(); |
| 129 | return boost::report_errors(); |
| 130 | } |
| 131 | #else |
| 132 | int main() |
| 133 | { |
| 134 | return 0; |
| 135 | } |
| 136 | #endif |
| 137 | |