34#ifndef _RWSTD_NO_EXT_CXX_0X
42template <
class T,
class U>
89#define _RETURN_TYPE_NAME(T) \
90 const char* get_type_name (T*) { return #T; }
92#define _RETURN_TYPE_NAME_CV(T) \
93 _RETURN_TYPE_NAME(T) \
94 _RETURN_TYPE_NAME(const T) \
95 _RETURN_TYPE_NAME(volatile T) \
96 _RETURN_TYPE_NAME(const volatile T)
101#ifndef _RWSTD_NO_WCHAR_T
117#ifndef _RWSTD_NO_LONG_LONG
129 "%s<%s>::type is%{?}n't%{;} %s; got %s",
130 trait, typeT, !same, typeU, typeV);
133#define _TEST(Trait,TypeT,TypeU) \
134 test_trait(__LINE__, \
135 std::is_same<Trait<TypeT>::type, TypeU>::value, \
136 #Trait, #TypeT, #TypeU, get_type_name((Trait<TypeT>::type*)0))
138#define TEST(Trait,TypeT,TypeU) \
139 _TEST(Trait, TypeT, TypeU); \
140 _TEST(Trait, const TypeT, const TypeU); \
141 _TEST(Trait, volatile TypeT, volatile TypeU); \
142 _TEST(Trait, const volatile TypeT, const volatile TypeU)
147 const char* trait_name,
149 size_t got_size,
size_t exp_size,
150 bool got_sign,
bool exp_sign,
151 bool got_c,
bool exp_c,
152 bool got_v,
bool exp_v)
154 const char* qualifiers[] = {
155 "unqualified",
"const",
"volatile",
"cv-qualified"
158 const unsigned got_cv = got_c + (got_v << 1);
159 const unsigned exp_cv = exp_c + (exp_v << 1);
161 const bool success = got_size == exp_size
163 && got_sign == exp_sign;
166 "%s<%s>::type is a %zu-byte %s %{?}un%{;}signed type, "
167 "expected a %zu-byte %s %{?}un%{;}signed type.",
169 got_size, qualifiers[got_cv], !got_sign,
170 exp_size, qualifiers[exp_cv], !exp_sign);
173#define _TEST_SIGN_AND_CV(Trait,Type,Signed) \
174 test_sign_and_cv(__LINE__, #Trait, #Type, \
175 sizeof (Trait<Type>::type), \
177 std::is_signed<Trait<Type>::type>::value, \
179 std::is_const<Trait<Type>::type>::value, \
180 std::is_const<Type>::value, \
181 std::is_volatile<Trait<Type>::type>::value, \
182 std::is_volatile<Type>::value)
184#define TEST_MAKE_SIGNED(Type) \
185 _TEST_SIGN_AND_CV (std::make_signed, Type, true); \
186 _TEST_SIGN_AND_CV (std::make_signed, const Type, true); \
187 _TEST_SIGN_AND_CV (std::make_signed, volatile Type, true); \
188 _TEST_SIGN_AND_CV (std::make_signed, const volatile Type, true)
190#define TEST_MAKE_UNSIGNED(Type) \
191 _TEST_SIGN_AND_CV (std::make_unsigned, Type, false); \
192 _TEST_SIGN_AND_CV (std::make_unsigned, const Type, false); \
193 _TEST_SIGN_AND_CV (std::make_unsigned, volatile Type, false); \
194 _TEST_SIGN_AND_CV (std::make_unsigned, const volatile Type, false)
198static void test_make_signed ()
200#if (_RWSTD_CHAR_MIN < 0)
201 TEST (std::make_signed,
char,
char);
203 TEST (std::make_signed,
char,
signed char);
206 TEST (std::make_signed,
signed char,
signed char);
207 TEST (std::make_signed,
unsigned char,
signed char);
209 TEST (std::make_signed,
signed short,
signed short);
210 TEST (std::make_signed,
unsigned short,
signed short);
212 TEST (std::make_signed,
signed int,
signed int);
213 TEST (std::make_signed,
unsigned int,
signed int);
215 TEST (std::make_signed,
signed long,
signed long);
216 TEST (std::make_signed,
unsigned long,
signed long);
218#ifndef _RWSTD_NO_LONG_LONG
219 TEST (std::make_signed,
signed long long,
signed long long);
220 TEST (std::make_signed,
unsigned long long,
signed long long);
225#ifndef _RWSTD_NO_NATIVE_WCHAR_T
237static void test_make_unsigned ()
239#if (_RWSTD_CHAR_MIN < 0)
240 TEST (std::make_unsigned,
char,
unsigned char);
242 TEST (std::make_unsigned,
char,
char);
245 TEST (std::make_unsigned,
signed char,
unsigned char);
246 TEST (std::make_unsigned,
unsigned char,
unsigned char);
248 TEST (std::make_unsigned,
signed short,
unsigned short);
249 TEST (std::make_unsigned,
unsigned short,
unsigned short);
251 TEST (std::make_unsigned,
signed int,
unsigned int);
252 TEST (std::make_unsigned,
unsigned int,
unsigned int);
254 TEST (std::make_unsigned,
signed long,
unsigned long);
255 TEST (std::make_unsigned,
unsigned long,
unsigned long);
257#ifndef _RWSTD_NO_LONG_LONG
258 TEST (std::make_unsigned,
signed long long,
unsigned long long);
259 TEST (std::make_unsigned,
unsigned long long,
unsigned long long);
264#ifndef _RWSTD_NO_NATIVE_WCHAR_T
281 test_make_unsigned ();
295 "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
303int main (
int argc,
char *argv[])
305 return rw_test (argc, argv, __FILE__,
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)