| 1 | #ifndef BOOST_SAFE_NUMERICS_TEST_VALUES_HPP |
| 2 | #define BOOST_SAFE_NUMERICS_TEST_VALUES_HPP |
| 3 | |
| 4 | // test_values.hpp |
| 5 | // |
| 6 | // Copyright (c) 2012 Robert Ramey |
| 7 | // |
| 8 | // Distributed under the Boost Software License, Version 1.0. (See |
| 9 | // accompanying file LICENSE_1_0.txt or copy at |
| 10 | // http://www.boost.org/LICENSE_1_0.txt) |
| 11 | |
| 12 | #include <cstdint> |
| 13 | #include <type_traits> // integral_constant |
| 14 | #include <boost/mp11/list.hpp> |
| 15 | #include <boost/mp11/algorithm.hpp> |
| 16 | |
| 17 | #define TEST_VALUE(type, value) std::integral_constant<type,(type)value> |
| 18 | |
| 19 | using test_values = boost::mp11::mp_list< |
| 20 | TEST_VALUE(std::int8_t,0x01), |
| 21 | TEST_VALUE(std::int8_t,0x7f), |
| 22 | TEST_VALUE(std::int8_t,0x80), |
| 23 | TEST_VALUE(std::int8_t,0xff), |
| 24 | TEST_VALUE(std::int16_t,0x0001), |
| 25 | TEST_VALUE(std::int16_t,0x7fff), |
| 26 | TEST_VALUE(std::int16_t,0x8000), |
| 27 | TEST_VALUE(std::int16_t,0xffff), |
| 28 | TEST_VALUE(std::int32_t,0x00000001), |
| 29 | TEST_VALUE(std::int32_t,0x7fffffff), |
| 30 | TEST_VALUE(std::int32_t,0x80000000), |
| 31 | TEST_VALUE(std::int32_t,0xffffffff), |
| 32 | TEST_VALUE(std::int64_t,0x0000000000000001), |
| 33 | TEST_VALUE(std::int64_t,0x7fffffffffffffff), |
| 34 | TEST_VALUE(std::int64_t,0x8000000000000000), |
| 35 | TEST_VALUE(std::int64_t,0xffffffffffffffff), |
| 36 | TEST_VALUE(std::uint8_t,0x01), |
| 37 | TEST_VALUE(std::uint8_t,0x7f), |
| 38 | TEST_VALUE(std::uint8_t,0x80), |
| 39 | TEST_VALUE(std::uint8_t,0xff), |
| 40 | TEST_VALUE(std::uint16_t,0x0001), |
| 41 | TEST_VALUE(std::uint16_t,0x7fff), |
| 42 | TEST_VALUE(std::uint16_t,0x8000), |
| 43 | TEST_VALUE(std::uint16_t,0xffff), |
| 44 | TEST_VALUE(std::uint32_t,0x00000001), |
| 45 | TEST_VALUE(std::uint32_t,0x7fffffff), |
| 46 | TEST_VALUE(std::uint32_t,0x80000000), |
| 47 | TEST_VALUE(std::uint32_t,0xffffffff), |
| 48 | TEST_VALUE(std::uint64_t,0x0000000000000001), |
| 49 | TEST_VALUE(std::uint64_t,0x7fffffffffffffff), |
| 50 | TEST_VALUE(std::uint64_t,0x8000000000000000), |
| 51 | TEST_VALUE(std::uint64_t,0xffffffffffffffff), |
| 52 | TEST_VALUE(std::int8_t,0x0) // uh oh - breaks test_types |
| 53 | >; |
| 54 | |
| 55 | /* |
| 56 | template<typename T> |
| 57 | using extract_value_type = typename T::value_type; |
| 58 | using test_types = boost::mp11:: mp_unique< |
| 59 | boost::mp11::mp_transform< |
| 60 | extract_value_type, |
| 61 | test_values |
| 62 | > |
| 63 | >; |
| 64 | */ |
| 65 | |
| 66 | using test_types = boost::mp11::mp_list< |
| 67 | std::int8_t, std::int16_t, std::int32_t, std::int64_t, |
| 68 | std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t |
| 69 | >; |
| 70 | |
| 71 | #endif |
| 72 | |