Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/range/test/partial_workaround.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 4.5 KB
Line 
1// Boost.Range library
2//
3//  Copyright Thorsten Ottosen 2003-2004. Use, modification and
4//  distribution is subject to the Boost Software License, Version
5//  1.0. (See accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt)
7//
8// For more information, see http://www.boost.org/libs/range/
9//
10
11#include <boost/config.hpp>
12#include <boost/detail/workaround.hpp>
13
14#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
15#  pragma warn -8091 // supress warning in Boost.Test
16#  pragma warn -8057 // unused argument argc/argv in Boost.Test
17#endif
18
19#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
20
21#include <boost/range/iterator.hpp>
22#include <boost/range/const_iterator.hpp>
23#include <boost/range/size_type.hpp>
24#include <boost/range/value_type.hpp>
25#include <boost/range/difference_type.hpp>
26#include <boost/range/result_iterator.hpp>
27
28#include <boost/range/begin.hpp>
29#include <boost/range/end.hpp>
30#include <boost/range/size.hpp>
31#include <boost/range/empty.hpp>
32#include <boost/range/detail/sfinae.hpp>
33
34#include <boost/static_assert.hpp>
35#include <boost/type_traits.hpp>
36#include <boost/test/test_tools.hpp>
37#include <iostream>
38#include <vector>
39
40using namespace boost;
41using namespace std;
42
43void check_partial_workaround()
44{
45    using namespace range_detail;
46    using type_traits::yes_type;
47    using type_traits::no_type;
48
49    //////////////////////////////////////////////////////////////////////
50    // string
51    //////////////////////////////////////////////////////////////////////
52    char*          c_ptr;
53    const char*    cc_ptr;
54    wchar_t*       w_ptr;
55    const wchar_t* cw_ptr;
56
57    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( c_ptr ) ) );
58    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cc_ptr ) ) );
59    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( w_ptr ) ) );
60    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_string_impl( cw_ptr ) ) );
61
62    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_char_ptr_impl( c_ptr ) ) );
63    BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_char_ptr_impl( cc_ptr ) ) );
64
65    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_wchar_t_ptr_impl( w_ptr ) ) );
66    BOOST_STATIC_ASSERT( sizeof( no_type ) == sizeof( is_wchar_t_ptr_impl( cw_ptr ) ) );
67   
68    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( c_ptr ) ) );
69    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_char_ptr_impl( cc_ptr ) ) );
70   
71    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( w_ptr ) ) );
72    BOOST_STATIC_ASSERT( sizeof( yes_type ) == sizeof( is_const_wchar_t_ptr_impl( cw_ptr ) ) );
73
74    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, 
75                          boost::range_detail::range< vector<int> >::type >::value ));
76    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_pair_, 
77                          boost::range_detail::range< pair<int,int> >::type >::value ));
78    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::array_, 
79                          boost::range_detail::range< int[42] >::type >::value ));
80    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::char_ptr_, 
81                          boost::range_detail::range< char* >::type >::value ));
82    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_char_ptr_, 
83                          boost::range_detail::range< const char* >::type >::value ));
84    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::wchar_t_ptr_, 
85                          boost::range_detail::range< wchar_t* >::type >::value ));
86    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::const_wchar_t_ptr_,
87                          boost::range_detail::range< const wchar_t* >::type >::value ));
88    BOOST_STATIC_ASSERT(( boost::is_same< boost::range_detail::std_container_, 
89                          boost::range_detail::range< vector<int> >::type >::value ));
90
91}
92
93
94#include <boost/test/unit_test.hpp>
95using boost::unit_test::test_suite;
96
97test_suite* init_unit_test_suite( int argc, char* argv[] )
98{
99    test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
100
101    test->add( BOOST_TEST_CASE( &check_partial_workaround ) );
102
103    return test;
104}
105
106#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
107
108#include <boost/test/unit_test.hpp>
109using boost::unit_test::test_suite;
110
111test_suite* init_unit_test_suite( int, char** )
112{
113    test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
114   
115    return test;
116}
117
118#endif
119
Note: See TracBrowser for help on using the repository browser.