Add out of bounds Ruby std::vector and std::array access testing
Also fix swig_assert_equal to work with nil as an expected input
This commit is contained in:
parent
fe09f05beb
commit
97b129de6c
3 changed files with 14 additions and 0 deletions
|
|
@ -108,6 +108,13 @@ ai = ArrayInt6.new([9, 8, 7, 6, 5, 4])
|
||||||
arrayInPtr(ai)
|
arrayInPtr(ai)
|
||||||
compare_containers(ai, [90, 80, 70, 60, 50, 40])
|
compare_containers(ai, [90, 80, 70, 60, 50, 40])
|
||||||
|
|
||||||
|
# indexing
|
||||||
|
ai = ArrayInt6.new([9, 8, 7, 6, 5, 4])
|
||||||
|
swig_assert_equal(ai[0], 9, binding)
|
||||||
|
swig_assert_equal(ai[5], 4, binding)
|
||||||
|
swig_assert_equal(ai[6], nil, binding)
|
||||||
|
swig_assert_equal(ai[-7], nil, binding)
|
||||||
|
|
||||||
# fill
|
# fill
|
||||||
ai.fill(111)
|
ai.fill(111)
|
||||||
compare_containers(ai, [111, 111, 111, 111, 111, 111])
|
compare_containers(ai, [111, 111, 111, 111, 111, 111])
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,11 @@ iv[1,3] = [6,7,8,9]
|
||||||
|
|
||||||
iv = IntVector.new([1,2,3,4])
|
iv = IntVector.new([1,2,3,4])
|
||||||
|
|
||||||
|
swig_assert_equal(iv[0], 1, binding)
|
||||||
|
swig_assert_equal(iv[3], 4, binding)
|
||||||
|
swig_assert_equal(iv[4], nil, binding)
|
||||||
|
swig_assert_equal(iv[-5], nil, binding)
|
||||||
|
|
||||||
iv[-1] = 9
|
iv[-1] = 9
|
||||||
iv[-4] = 6
|
iv[-4] = 6
|
||||||
swig_assert_equal(iv.to_s, '6239', binding)
|
swig_assert_equal(iv.to_s, '6239', binding)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ end
|
||||||
# msg - optional additional message to print
|
# msg - optional additional message to print
|
||||||
#
|
#
|
||||||
def swig_assert_equal( a, b, scope = nil, msg = nil )
|
def swig_assert_equal( a, b, scope = nil, msg = nil )
|
||||||
|
a = 'nil' if a == nil
|
||||||
|
b = 'nil' if b == nil
|
||||||
begin
|
begin
|
||||||
check = "#{a} == #{b}"
|
check = "#{a} == #{b}"
|
||||||
if scope.kind_of? Binding
|
if scope.kind_of? Binding
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue