make_signed_test.cpp 5.7 KB

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