summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/python/test/select_from_python_test.cpp
blob: bb60962a370c0385e0095084edac3932729d1916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// Copyright David Abrahams 2004. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/python/converter/arg_from_python.hpp>
#include <boost/python/type_id.hpp>
#include <iostream>

// gcc 2.95.x, MIPSpro 7.3.1.3 and IBM XL for Linux linker seem to demand this definition
#if (defined(__GNUC__) && (__GNUC__ < 3)) \
 || (defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238)) \
 || (defined(__IBMCPP__) && defined(__linux__))
namespace boost { namespace python {
BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
{
    return true;
}
}}
#endif

int result;

#define ASSERT_SAME(T1,T2) \
       if (!is_same< T1, T2 >::value) { \
             std::cout << "*********************\n"; \
             std::cout << python::type_id< T1 >() << " != " << python::type_id< T2 >() << "\n"; \
             std::cout << "*********************\n"; \
             result = 1; \
       }

int main()
{
    using namespace boost::python::converter;
    using namespace boost;


    ASSERT_SAME(
        select_arg_from_python<int>::type, arg_rvalue_from_python<int>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const>::type, arg_rvalue_from_python<int const>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile>::type, arg_rvalue_from_python<int volatile>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile>::type, arg_rvalue_from_python<int const volatile>
        );



    ASSERT_SAME(
        select_arg_from_python<int*>::type, pointer_arg_from_python<int*>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const*>::type, pointer_arg_from_python<int const*>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile*>::type, pointer_arg_from_python<int volatile*>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile*>::type, pointer_arg_from_python<int const volatile*>
        );




    ASSERT_SAME(
        select_arg_from_python<int&>::type, reference_arg_from_python<int&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const&>::type, arg_rvalue_from_python<int const&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile&>::type, reference_arg_from_python<int volatile&>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile&>::type, reference_arg_from_python<int const volatile&>
        );



    ASSERT_SAME(
        select_arg_from_python<int*&>::type, reference_arg_from_python<int*&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const*&>::type, reference_arg_from_python<int const*&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile*&>::type, reference_arg_from_python<int volatile*&>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile*&>::type, reference_arg_from_python<int const volatile*&>
        );



    ASSERT_SAME(
        select_arg_from_python<int* const&>::type, pointer_cref_arg_from_python<int*const&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const* const&>::type, pointer_cref_arg_from_python<int const*const&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile* const&>::type, pointer_cref_arg_from_python<int volatile*const&>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile* const&>::type, pointer_cref_arg_from_python<int const volatile*const&>
        );



    ASSERT_SAME(
        select_arg_from_python<int*volatile&>::type, reference_arg_from_python<int*volatile&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const*volatile&>::type, reference_arg_from_python<int const*volatile&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile*volatile&>::type, reference_arg_from_python<int volatile*volatile&>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile*volatile&>::type, reference_arg_from_python<int const volatile*volatile&>
        );



    ASSERT_SAME(
        select_arg_from_python<int*const volatile&>::type, reference_arg_from_python<int*const volatile&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int const*const volatile&>::type, reference_arg_from_python<int const*const volatile&>
        );
    
    ASSERT_SAME(
        select_arg_from_python<int volatile*const volatile&>::type, reference_arg_from_python<int volatile*const volatile&>
        );

    ASSERT_SAME(
        select_arg_from_python<int const volatile*const volatile&>::type, reference_arg_from_python<int const volatile*const volatile&>
        );
    return result;
}