2 // (C) Copyright John Maddock 2000.
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.boost.org/LICENSE_1_0.txt)
10 #include <boost/config.hpp>
12 #if defined(_WIN32_WCE) && defined(BOOST_MSVC)
13 #pragma warning(disable:4201)
16 #include <boost/noncopyable.hpp>
21 // we have to turn off these warnings otherwise we get swamped by the things:
22 #pragma option -w-8008 -w-8066
26 // We have to turn off warnings that occur within the test suite:
27 #pragma warning(disable:4127)
30 // remark #1418: external function definition with no prior declaration
31 // remark #981: operands are evaluated in unspecified order
32 #pragma warning(disable:1418 981)
36 // turn off warnings from this header:
38 #pragma warning(disable:444)
42 // basic configuration:
48 //#define TYPE_TRAITS(x) <type_traits>
49 //#define TYPE_COMPARE(x) <type_compare>
50 //#define TYPE_TRANSFORM(x) <type_transform>
56 //#define TYPE_TRAITS(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
57 //#define TYPE_COMPARE(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
58 //#define TYPE_TRANSFORM(x) BOOST_STRINGIZE(boost/type_traits/x.hpp)
63 // replacements for Unit test macros:
67 #define BOOST_CHECK_MESSAGE(pred, message)\
71 std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\
76 #define BOOST_WARN_MESSAGE(pred, message)\
80 std::cerr << __FILE__ << ":" << __LINE__ << ": " << message << std::endl;\
84 #define BOOST_TEST_MESSAGE(message)\
85 do{ std::cout << __FILE__ << ":" << __LINE__ << ": " << message << std::endl; }while(0)
87 #define BOOST_CHECK(pred)\
90 std::cout << __FILE__ << ":" << __LINE__ << ": Error in " << BOOST_STRINGIZE(pred) << std::endl;\
95 #define TT_TEST_BEGIN(trait_name)\
97 #define TT_TEST_END return error_count; }
100 #define TRANSFORM_CHECK(name, from_suffix, to_suffix)\
101 BOOST_CHECK_TYPE(bool to_suffix, name<bool from_suffix>::type);\
102 BOOST_CHECK_TYPE(char to_suffix, name<char from_suffix>::type);\
103 BOOST_CHECK_TYPE(wchar_t to_suffix, name<wchar_t from_suffix>::type);\
104 BOOST_CHECK_TYPE(signed char to_suffix, name<signed char from_suffix>::type);\
105 BOOST_CHECK_TYPE(unsigned char to_suffix, name<unsigned char from_suffix>::type);\
106 BOOST_CHECK_TYPE(short to_suffix, name<short from_suffix>::type);\
107 BOOST_CHECK_TYPE(unsigned short to_suffix, name<unsigned short from_suffix>::type);\
108 BOOST_CHECK_TYPE(int to_suffix, name<int from_suffix>::type);\
109 BOOST_CHECK_TYPE(unsigned int to_suffix, name<unsigned int from_suffix>::type);\
110 BOOST_CHECK_TYPE(long to_suffix, name<long from_suffix>::type);\
111 BOOST_CHECK_TYPE(unsigned long to_suffix, name<unsigned long from_suffix>::type);\
112 BOOST_CHECK_TYPE(float to_suffix, name<float from_suffix>::type);\
113 BOOST_CHECK_TYPE(long double to_suffix, name<long double from_suffix>::type);\
114 BOOST_CHECK_TYPE(double to_suffix, name<double from_suffix>::type);\
115 BOOST_CHECK_TYPE(UDT to_suffix, name<UDT from_suffix>::type);\
116 BOOST_CHECK_TYPE(enum1 to_suffix, name<enum1 from_suffix>::type);
118 #define BOOST_DUMMY_MACRO_PARAM /**/
120 #define BOOST_DECL_TRANSFORM_TEST(name, type, from, to)\
121 void name(){ TRANSFORM_CHECK(type, from, to) }
122 #define BOOST_DECL_TRANSFORM_TEST3(name, type, from)\
123 void name(){ TRANSFORM_CHECK(type, from, BOOST_DUMMY_MACRO_PARAM) }
124 #define BOOST_DECL_TRANSFORM_TEST2(name, type, to)\
125 void name(){ TRANSFORM_CHECK(type, BOOST_DUMMY_MACRO_PARAM, to) }
126 #define BOOST_DECL_TRANSFORM_TEST0(name, type)\
127 void name(){ TRANSFORM_CHECK(type, BOOST_DUMMY_MACRO_PARAM, BOOST_DUMMY_MACRO_PARAM) }
132 // VC++ emits an awful lot of warnings unless we define these:
134 # pragma warning(disable:4800)
138 // define some test types:
140 enum enum_UDT{ one, two, three };
146 UDT& operator=(const UDT&);
156 typedef int(*f2)(int);
157 typedef int(*f3)(int, bool);
158 typedef void (UDT::*mf1)();
159 typedef int (UDT::*mf2)();
160 typedef int (UDT::*mf3)(int);
161 typedef int (UDT::*mf4)(int, float);
162 typedef int (UDT::*mp);
163 typedef int (UDT::*cmf)(int) const;
165 // cv-qualifiers applied to reference types should have no effect
166 // declare these here for later use with is_reference and remove_reference:
168 # pragma warning(push)
169 # pragma warning(disable: 4181)
170 # elif defined(BOOST_INTEL)
171 # pragma warning(push)
172 # pragma warning(disable: 21)
175 // This is intentional:
176 // r_type and cr_type should be the same type
177 // but some compilers wrongly apply cv-qualifiers
178 // to reference types (this may generate a warning
179 // on some compilers):
183 typedef const r_type cr_type;
185 // recent Intel compilers generate a hard error on the above:
186 typedef r_type cr_type;
189 # pragma warning(pop)
190 # elif defined(BOOST_INTEL)
191 # pragma warning(pop)
192 # pragma warning(disable: 985) // identifier truncated in debug information
195 struct POD_UDT { int x; };
199 empty_UDT(const empty_UDT&);
201 empty_UDT& operator=(const empty_UDT&);
202 bool operator==(const empty_UDT&)const;
206 bool operator==(const empty_POD_UDT&)const
220 union empty_union_UDT
224 union empty_POD_union_UDT{};
226 struct nothrow_copy_UDT
229 nothrow_copy_UDT(const nothrow_copy_UDT&)throw();
230 ~nothrow_copy_UDT(){}
231 nothrow_copy_UDT& operator=(const nothrow_copy_UDT&);
232 bool operator==(const nothrow_copy_UDT&)const
236 struct nothrow_assign_UDT
238 nothrow_assign_UDT();
239 nothrow_assign_UDT(const nothrow_assign_UDT&);
240 ~nothrow_assign_UDT(){};
241 nothrow_assign_UDT& operator=(const nothrow_assign_UDT&)throw(){ return *this; }
242 bool operator==(const nothrow_assign_UDT&)const
246 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
247 struct nothrow_move_UDT
250 nothrow_move_UDT(nothrow_move_UDT&&) throw();
251 nothrow_move_UDT& operator=(nothrow_move_UDT&&) throw();
252 bool operator==(const nothrow_move_UDT&)const
258 struct nothrow_construct_UDT
260 nothrow_construct_UDT()throw();
261 nothrow_construct_UDT(const nothrow_construct_UDT&);
262 ~nothrow_construct_UDT(){};
263 nothrow_construct_UDT& operator=(const nothrow_construct_UDT&){ return *this; }
264 bool operator==(const nothrow_construct_UDT&)const
270 class Derived : public Base { };
271 class Derived2 : public Base { };
272 class MultiBase : public Derived, public Derived2 {};
273 class PrivateBase : private Base {};
275 class NonDerived { };
292 struct VD : public VB
297 // struct non_pointer:
298 // used to verify that is_pointer does not return
299 // true for class types that implement operator void*()
303 operator void*(){return this;}
305 struct non_int_pointer
308 operator int*(){return &i;}
310 struct int_constructible
312 int_constructible(int);
314 struct int_convertible
320 // used to verify that is_empty does not emit
321 // spurious warnings or errors.
323 struct non_empty : private boost::noncopyable
328 // abstract base classes:
332 virtual ~test_abc1();
333 test_abc1(const test_abc1&);
334 test_abc1& operator=(const test_abc1&);
335 virtual void foo() = 0;
336 virtual void foo2() = 0;
341 virtual ~test_abc2();
342 virtual void foo() = 0;
343 virtual void foo2() = 0;
346 struct test_abc3 : public test_abc1
348 virtual void foo3() = 0;
351 struct incomplete_type;
353 struct polymorphic_base
355 virtual ~polymorphic_base();
356 virtual void method();
359 struct polymorphic_derived1 : public polymorphic_base
363 struct polymorphic_derived2 : public polymorphic_base
365 virtual void method();
368 #ifndef BOOST_NO_CXX11_FINAL
369 struct final_UDT final
371 struct polymorphic_derived_final final : public polymorphic_derived2
376 struct virtual_inherit1 : public virtual Base { };
377 struct virtual_inherit2 : public virtual_inherit1 { };
378 struct virtual_inherit3 : private virtual Base {};
379 struct virtual_inherit4 : public virtual boost::noncopyable {};
380 struct virtual_inherit5 : public virtual int_convertible {};
381 struct virtual_inherit6 : public virtual Base { virtual ~virtual_inherit6()throw(); };
383 typedef void foo0_t();
384 typedef void foo1_t(int);
385 typedef void foo2_t(int&, double);
386 typedef void foo3_t(int&, bool, int, int);
387 typedef void foo4_t(int, bool, int*, int[], int, int, int, int, int);
389 struct trivial_except_construct
391 trivial_except_construct();
395 struct trivial_except_destroy
397 ~trivial_except_destroy();
401 struct trivial_except_copy
403 trivial_except_copy(trivial_except_copy const&);
407 struct trivial_except_assign
409 trivial_except_assign& operator=(trivial_except_assign const&);
421 wrap& operator=(const wrap&);