1 | |
---|
2 | // Copyright Aleksey Gurtovoy 2000-2004 |
---|
3 | // |
---|
4 | // Distributed under the Boost Software License, Version 1.0. |
---|
5 | // (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | // See http://www.boost.org/libs/mpl for documentation. |
---|
9 | |
---|
10 | // $Source: /cvsroot/boost/boost/libs/mpl/test/assert.cpp,v $ |
---|
11 | // $Date: 2004/09/18 06:34:19 $ |
---|
12 | // $Revision: 1.3 $ |
---|
13 | |
---|
14 | #include <boost/mpl/assert.hpp> |
---|
15 | |
---|
16 | #include <boost/type_traits/is_same.hpp> |
---|
17 | #include <boost/type_traits/is_pointer.hpp> |
---|
18 | |
---|
19 | |
---|
20 | BOOST_MPL_ASSERT(( boost::is_same<int,int> )); |
---|
21 | BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); |
---|
22 | BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); |
---|
23 | BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); |
---|
24 | BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); |
---|
25 | BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); |
---|
26 | BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); |
---|
27 | BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () ); |
---|
28 | |
---|
29 | namespace my { |
---|
30 | BOOST_MPL_ASSERT(( boost::is_same<int,int> )); |
---|
31 | BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); |
---|
32 | BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); |
---|
33 | BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); |
---|
34 | BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); |
---|
35 | BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); |
---|
36 | BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); |
---|
37 | BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () ); |
---|
38 | BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () ); |
---|
39 | } |
---|
40 | |
---|
41 | template< typename T > |
---|
42 | struct her |
---|
43 | { |
---|
44 | BOOST_MPL_ASSERT(( boost::is_same<void,T> )); |
---|
45 | BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); |
---|
46 | BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); |
---|
47 | BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); |
---|
48 | BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); |
---|
49 | BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); |
---|
50 | BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); |
---|
51 | BOOST_MPL_ASSERT_MSG( true, CLASS_SCOPE_ERROR, () ); |
---|
52 | #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
---|
53 | BOOST_MPL_ASSERT_MSG( true, ANOTHER_CLASS_SCOPE_ERROR, (types<int, T>) ); |
---|
54 | #endif |
---|
55 | |
---|
56 | void f() |
---|
57 | { |
---|
58 | BOOST_MPL_ASSERT(( boost::is_same<void,T> )); |
---|
59 | BOOST_MPL_ASSERT(( boost::is_pointer<T*> )); |
---|
60 | BOOST_MPL_ASSERT_NOT(( boost::is_same<int,T> )); |
---|
61 | BOOST_MPL_ASSERT_NOT(( boost::is_pointer<T> )); |
---|
62 | BOOST_MPL_ASSERT_RELATION( sizeof(T*), >, 1 ); |
---|
63 | BOOST_MPL_ASSERT_RELATION( 1, <, sizeof(T*) ); |
---|
64 | #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) |
---|
65 | BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); |
---|
66 | #endif |
---|
67 | BOOST_MPL_ASSERT_MSG( true, MEMBER_FUNCTION_SCOPE_ERROR, () ); |
---|
68 | #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) |
---|
69 | BOOST_MPL_ASSERT_MSG( true, ANOTHER_MEMBER_FUNCTION_SCOPE_ERROR, (types<int, T>) ); |
---|
70 | #endif |
---|
71 | } |
---|
72 | }; |
---|
73 | |
---|
74 | int main() |
---|
75 | { |
---|
76 | her<void> h; |
---|
77 | h.f(); |
---|
78 | |
---|
79 | BOOST_MPL_ASSERT(( boost::is_same<int,int> )); |
---|
80 | BOOST_MPL_ASSERT(( boost::is_pointer<int*> )); |
---|
81 | BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> )); |
---|
82 | BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> )); |
---|
83 | BOOST_MPL_ASSERT_RELATION( 5, >, 1 ); |
---|
84 | BOOST_MPL_ASSERT_RELATION( 1, <, 5 ); |
---|
85 | BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) ); |
---|
86 | BOOST_MPL_ASSERT_MSG( true, FUNCTION_SCOPE_ERROR, () ); |
---|
87 | BOOST_MPL_ASSERT_MSG( true, ANOTHER_FUNCTION_SCOPE_ERROR, () ); |
---|
88 | |
---|
89 | return 0; |
---|
90 | } |
---|