Skip to content

Commit e431318

Browse files
committed
Added some more tests
[SVN r14437]
1 parent c15812a commit e431318

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

test/Jamfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ run select_from_python_test.cpp ../src/converter/type_id.cpp
116116
: $(UNIT_TEST_PROPERTIES)
117117
;
118118

119+
run select_arg_to_python_test.cpp ../src/converter/type_id.cpp
120+
: # command-line args
121+
: # input files
122+
: $(UNIT_TEST_PROPERTIES)
123+
;
124+
119125
if $(TEST_EXPECTED_FAILURES)
120126
{
121127
compile-fail ./raw_pyobject_fail1.cpp : $(PYTHON_PROPERTIES) ;

test/callbacks.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <boost/python/object.hpp>
1515

1616
using namespace boost::python;
17+
BOOST_STATIC_ASSERT(converter::is_object_manager<handle<> >::value);
1718

1819
int apply_int_int(PyObject* f, int x)
1920
{

test/select_arg_to_python_test.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#include <boost/python/converter/arg_to_python.hpp>
2+
#include <boost/python/type_id.hpp>
3+
#include <boost/python/handle.hpp>
4+
#include <boost/python/object.hpp>
5+
#include <iostream>
6+
7+
// gcc 2.95.x and MIPSpro 7.3.1.3 linker seem to demand this definition
8+
#if ((defined(__GNUC__) && __GNUC__ < 3)) \
9+
|| (defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238))
10+
namespace boost { namespace python {
11+
BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
12+
{
13+
return true;
14+
}
15+
}}
16+
#endif
17+
18+
int result;
19+
20+
#define ASSERT_SAME(T1,T2) \
21+
if (!is_same< T1, T2 >::value) { \
22+
std::cout << "*********************\n"; \
23+
std::cout << python::type_id< T1 >() << " != " << python::type_id< T2 >() << "\n"; \
24+
std::cout << "*********************\n"; \
25+
result = 1; \
26+
}
27+
28+
int main()
29+
{
30+
using namespace boost::python::converter::detail;
31+
using namespace boost::python::converter;
32+
using namespace boost::python;
33+
using namespace boost;
34+
35+
36+
ASSERT_SAME(
37+
select_arg_to_python<int>::type, value_arg_to_python<int>
38+
);
39+
40+
ASSERT_SAME(
41+
select_arg_to_python<reference_wrapper<int> >::type, reference_arg_to_python<int>
42+
);
43+
44+
ASSERT_SAME(
45+
select_arg_to_python<pointer_wrapper<int> >::type, pointer_shallow_arg_to_python<int>
46+
);
47+
48+
ASSERT_SAME(
49+
select_arg_to_python<int*>::type, pointer_deep_arg_to_python<int*>
50+
);
51+
52+
ASSERT_SAME(
53+
select_arg_to_python<handle<> >::type, object_manager_arg_to_python<handle<> >
54+
);
55+
56+
ASSERT_SAME(
57+
select_arg_to_python<object>::type, object_manager_arg_to_python<object>
58+
);
59+
60+
ASSERT_SAME(
61+
select_arg_to_python<char[20]>::type, arg_to_python<char const*>
62+
);
63+
64+
return result;
65+
}

0 commit comments

Comments
 (0)