Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/mpl/test/assert.cpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 3.2 KB
Line 
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
20BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
21BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
22BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
23BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
24BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
25BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
26BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
27BOOST_MPL_ASSERT_MSG( true, ANOTHER_GLOBAL_SCOPE_ERROR, () );
28
29namespace my {
30BOOST_MPL_ASSERT(( boost::is_same<int,int> ));
31BOOST_MPL_ASSERT(( boost::is_pointer<int*> ));
32BOOST_MPL_ASSERT_NOT(( boost::is_same<int,long> ));
33BOOST_MPL_ASSERT_NOT(( boost::is_pointer<int> ));
34BOOST_MPL_ASSERT_RELATION( 5, >, 1 );
35BOOST_MPL_ASSERT_RELATION( 1, <, 5 );
36BOOST_MPL_ASSERT_MSG( true, GLOBAL_SCOPE_ERROR, (int,long) );
37BOOST_MPL_ASSERT_MSG( true, NAMESPACE_SCOPE_ERROR, () );
38BOOST_MPL_ASSERT_MSG( true, ANOTHER_NAMESPACE_SCOPE_ERROR, () );
39}
40
41template< typename T >
42struct 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
74int 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}
Note: See TracBrowser for help on using the repository browser.