mirror of https://github.com/swig/swig
[python] Replace uses of assert in testsuite
We're not supposed to assert for this, as mentioned in #1488.
This commit is contained in:
parent
16238102c7
commit
25f996a5c8
|
@ -1,11 +1,15 @@
|
||||||
import cpp11_template_explicit
|
import cpp11_template_explicit
|
||||||
|
|
||||||
|
def swig_assert_isinstance(a, b):
|
||||||
|
if not isinstance(a, b):
|
||||||
|
raise RuntimeError(str(a) + " not an instance of " + str(b))
|
||||||
|
|
||||||
# Call variants of the same templated function
|
# Call variants of the same templated function
|
||||||
t1 = cpp11_template_explicit.my_templated_function_int (1,1.0)
|
t1 = cpp11_template_explicit.my_templated_function_int (1,1.0)
|
||||||
t2 = cpp11_template_explicit.my_templated_function_A (2,2.0)
|
t2 = cpp11_template_explicit.my_templated_function_A (2,2.0)
|
||||||
t3 = cpp11_template_explicit.my_templated_function_TemperInt(3,3.0)
|
t3 = cpp11_template_explicit.my_templated_function_TemperInt(3,3.0)
|
||||||
|
|
||||||
# Check return types
|
# Check return types
|
||||||
assert isinstance(t1,int)
|
swig_assert_isinstance(t1,int)
|
||||||
assert isinstance(t2,cpp11_template_explicit.A)
|
swig_assert_isinstance(t2,cpp11_template_explicit.A)
|
||||||
assert isinstance(t3,cpp11_template_explicit.TemperInt)
|
swig_assert_isinstance(t3,cpp11_template_explicit.TemperInt)
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
from li_boost_shared_ptr_director import *
|
from li_boost_shared_ptr_director import *
|
||||||
|
|
||||||
|
def swig_assert_equal(a, b):
|
||||||
|
if a != b:
|
||||||
|
raise RuntimeError(str(a) + " != " + str(b))
|
||||||
|
|
||||||
class Derived(Base):
|
class Derived(Base):
|
||||||
def __init__(self, flag):
|
def __init__(self, flag):
|
||||||
self.return_none = flag
|
self.return_none = flag
|
||||||
|
@ -59,22 +63,22 @@ class Derived(Base):
|
||||||
a = Derived(False)
|
a = Derived(False)
|
||||||
b = Derived(True)
|
b = Derived(True)
|
||||||
|
|
||||||
assert call_ret_c_shared_ptr(a) == 1
|
swig_assert_equal(call_ret_c_shared_ptr(a), 1)
|
||||||
assert call_ret_c_shared_ptr(b) == -1
|
swig_assert_equal(call_ret_c_shared_ptr(b), -1)
|
||||||
assert call_ret_c_by_value(a) == 1
|
swig_assert_equal(call_ret_c_by_value(a), 1)
|
||||||
|
|
||||||
assert call_take_c_by_value(a) == 5
|
swig_assert_equal(call_take_c_by_value(a), 5)
|
||||||
assert call_take_c_by_ref(a) == 6
|
swig_assert_equal(call_take_c_by_ref(a), 6)
|
||||||
assert call_take_c_by_pointer(a) == 7
|
swig_assert_equal(call_take_c_by_pointer(a), 7)
|
||||||
assert call_take_c_by_pointer_ref(a) == 8
|
swig_assert_equal(call_take_c_by_pointer_ref(a), 8)
|
||||||
assert call_take_c_shared_ptr_by_value(a) == 9
|
swig_assert_equal(call_take_c_shared_ptr_by_value(a), 9)
|
||||||
assert call_take_c_shared_ptr_by_ref(a) == 10
|
swig_assert_equal(call_take_c_shared_ptr_by_ref(a), 10)
|
||||||
assert call_take_c_shared_ptr_by_pointer(a) == 11
|
swig_assert_equal(call_take_c_shared_ptr_by_pointer(a), 11)
|
||||||
assert call_take_c_shared_ptr_by_pointer_ref(a) == 12
|
swig_assert_equal(call_take_c_shared_ptr_by_pointer_ref(a), 12)
|
||||||
|
|
||||||
assert call_take_c_by_pointer_with_null(a) == -2
|
swig_assert_equal(call_take_c_by_pointer_with_null(a), -2)
|
||||||
assert call_take_c_by_pointer_ref_with_null(a) == -3
|
swig_assert_equal(call_take_c_by_pointer_ref_with_null(a), -3)
|
||||||
assert call_take_c_shared_ptr_by_value_with_null(a) == -4
|
swig_assert_equal(call_take_c_shared_ptr_by_value_with_null(a), -4)
|
||||||
assert call_take_c_shared_ptr_by_ref_with_null(a) == -5
|
swig_assert_equal(call_take_c_shared_ptr_by_ref_with_null(a), -5)
|
||||||
assert call_take_c_shared_ptr_by_pointer_with_null(a) == -6
|
swig_assert_equal(call_take_c_shared_ptr_by_pointer_with_null(a), -6)
|
||||||
assert call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -7
|
swig_assert_equal(call_take_c_shared_ptr_by_pointer_ref_with_null(a), -7)
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
from using_member import *
|
from using_member import *
|
||||||
|
|
||||||
|
def swig_assert_equal(a, b):
|
||||||
|
if a != b:
|
||||||
|
raise RuntimeError(str(a) + " != " + str(b))
|
||||||
|
|
||||||
b = B()
|
b = B()
|
||||||
assert b.get(int(1)) == 10
|
swig_assert_equal(b.get(int(1)), 10)
|
||||||
assert b.get(float(1)) == 20
|
swig_assert_equal(b.get(float(1)), 20)
|
||||||
|
|
||||||
bb = BB()
|
bb = BB()
|
||||||
assert bb.greater(int(1)) == 0
|
swig_assert_equal(bb.greater(int(1)), 0)
|
||||||
assert bb.greater(float(1)) == 1
|
swig_assert_equal(bb.greater(float(1)), 1)
|
||||||
assert bb.great(True) == 2
|
swig_assert_equal(bb.great(True), 2)
|
||||||
|
|
Loading…
Reference in New Issue