1 
2 //  (C) Copyright John Maddock 2007.
3 //  Use, modification and distribution are subject to the
4 //  Boost Software License, Version 1.0. (See accompanying file
5 //  LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
6 
7 #include "test.hpp"
8 #include "check_type.hpp"
9 #include "check_integral_constant.hpp"
10 #ifdef TEST_STD
11 #  include <type_traits>
12 #else
13 #  include <boost/type_traits/make_signed.hpp>
14 #endif
15 
16 TT_TEST_BEGIN(make_signed)
17 // signed types:
18 BOOST_CHECK_TYPE(::tt::make_signed<signed char>::type, signed char);
19 BOOST_CHECK_TYPE(::tt::make_signed<short>::type, short);
20 BOOST_CHECK_TYPE(::tt::make_signed<int>::type, int);
21 BOOST_CHECK_TYPE(::tt::make_signed<long>::type, long);
22 #ifdef BOOST_HAS_LONG_LONG
23 BOOST_CHECK_TYPE(::tt::make_signed<boost::long_long_type>::type, boost::long_long_type);
24 #elif defined(BOOST_HAS_MS_INT64)
25 BOOST_CHECK_TYPE(::tt::make_signed<__int64>::type, __int64);
26 #endif
27 // const signed types:
28 BOOST_CHECK_TYPE(::tt::make_signed<const signed char>::type, const signed char);
29 BOOST_CHECK_TYPE(::tt::make_signed<const short>::type, const short);
30 BOOST_CHECK_TYPE(::tt::make_signed<const int>::type, const int);
31 BOOST_CHECK_TYPE(::tt::make_signed<const long>::type, const long);
32 #ifdef BOOST_HAS_LONG_LONG
33 BOOST_CHECK_TYPE(::tt::make_signed<const boost::long_long_type>::type, const boost::long_long_type);
34 #elif defined(BOOST_HAS_MS_INT64)
35 BOOST_CHECK_TYPE(::tt::make_signed<const __int64>::type, const __int64);
36 #endif
37 // volatile signed types:
38 BOOST_CHECK_TYPE(::tt::make_signed<volatile signed char>::type, volatile signed char);
39 BOOST_CHECK_TYPE(::tt::make_signed<volatile short>::type, volatile short);
40 BOOST_CHECK_TYPE(::tt::make_signed<volatile int>::type, volatile int);
41 BOOST_CHECK_TYPE(::tt::make_signed<volatile long>::type, volatile long);
42 #ifdef BOOST_HAS_LONG_LONG
43 BOOST_CHECK_TYPE(::tt::make_signed<volatile boost::long_long_type>::type, volatile boost::long_long_type);
44 #elif defined(BOOST_HAS_MS_INT64)
45 BOOST_CHECK_TYPE(::tt::make_signed<volatile __int64>::type, volatile __int64);
46 #endif
47 // const volatile signed types:
48 BOOST_CHECK_TYPE(::tt::make_signed<const volatile signed char>::type, const volatile signed char);
49 BOOST_CHECK_TYPE(::tt::make_signed<const volatile short>::type, const volatile short);
50 BOOST_CHECK_TYPE(::tt::make_signed<const volatile int>::type, const volatile int);
51 BOOST_CHECK_TYPE(::tt::make_signed<const volatile long>::type, const volatile long);
52 #ifdef BOOST_HAS_LONG_LONG
53 BOOST_CHECK_TYPE(::tt::make_signed<const volatile boost::long_long_type>::type, const volatile boost::long_long_type);
54 #elif defined(BOOST_HAS_MS_INT64)
55 BOOST_CHECK_TYPE(::tt::make_signed<const volatile __int64>::type, const volatile __int64);
56 #endif
57 
58 // unsigned types:
59 BOOST_CHECK_TYPE(::tt::make_signed<unsigned char>::type, signed char);
60 BOOST_CHECK_TYPE(::tt::make_signed<unsigned short>::type, short);
61 BOOST_CHECK_TYPE(::tt::make_signed<unsigned int>::type, int);
62 BOOST_CHECK_TYPE(::tt::make_signed<unsigned long>::type, long);
63 #ifdef BOOST_HAS_LONG_LONG
64 BOOST_CHECK_TYPE(::tt::make_signed<boost::ulong_long_type>::type, boost::long_long_type);
65 #elif defined(BOOST_HAS_MS_INT64)
66 BOOST_CHECK_TYPE(::tt::make_signed<unsigned __int64>::type, __int64);
67 #endif
68 // const unsigned types:
69 BOOST_CHECK_TYPE(::tt::make_signed<const unsigned char>::type, const signed char);
70 BOOST_CHECK_TYPE(::tt::make_signed<const unsigned short>::type, const short);
71 BOOST_CHECK_TYPE(::tt::make_signed<const unsigned int>::type, const int);
72 BOOST_CHECK_TYPE(::tt::make_signed<const unsigned long>::type, const long);
73 #ifdef BOOST_HAS_LONG_LONG
74 BOOST_CHECK_TYPE(::tt::make_signed<const boost::ulong_long_type>::type, const boost::long_long_type);
75 #elif defined(BOOST_HAS_MS_INT64)
76 BOOST_CHECK_TYPE(::tt::make_signed<const unsigned __int64>::type, const __int64);
77 #endif
78 // volatile unsigned types:
79 BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned char>::type, volatile signed char);
80 BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned short>::type, volatile short);
81 BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned int>::type, volatile int);
82 BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned long>::type, volatile long);
83 #ifdef BOOST_HAS_LONG_LONG
84 BOOST_CHECK_TYPE(::tt::make_signed<volatile boost::ulong_long_type>::type, volatile boost::long_long_type);
85 #elif defined(BOOST_HAS_MS_INT64)
86 BOOST_CHECK_TYPE(::tt::make_signed<volatile unsigned __int64>::type, volatile __int64);
87 #endif
88 // const volatile unsigned types:
89 BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned char>::type, const volatile signed char);
90 BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned short>::type, const volatile short);
91 BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned int>::type, const volatile int);
92 BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned long>::type, const volatile long);
93 #ifdef BOOST_HAS_LONG_LONG
94 BOOST_CHECK_TYPE(::tt::make_signed<const volatile boost::ulong_long_type>::type, const volatile boost::long_long_type);
95 #elif defined(BOOST_HAS_MS_INT64)
96 BOOST_CHECK_TYPE(::tt::make_signed<const volatile unsigned __int64>::type, const volatile __int64);
97 #endif
98 #ifdef BOOST_HAS_INT128
99 BOOST_CHECK_TYPE(::tt::make_signed<boost::int128_type>::type, boost::int128_type);
100 BOOST_CHECK_TYPE(::tt::make_signed<boost::uint128_type>::type, boost::int128_type);
101 #endif
102 
103 // character types:
104 BOOST_CHECK_TYPE(::tt::make_signed<char>::type, signed char);
105 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_signed<wchar_t>::type>::value, true);
106 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_signed< ::tt::make_signed<wchar_t>::type>::value, true);
107 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_integral< ::tt::make_signed<enum_UDT>::type>::value, true);
108 BOOST_CHECK_INTEGRAL_CONSTANT(::tt::is_signed< ::tt::make_signed<enum_UDT>::type>::value, true);
109 TT_TEST_END
110 
111 
112