Merge branch 'master' into doxygen
Fix the usual conflicts in autodoc unit test due to fixing the divergences in autodoc generation between builtin and default cases in this branch.
This commit is contained in:
commit
db65ae5aea
371 changed files with 9815 additions and 3191 deletions
|
|
@ -11,23 +11,36 @@ top_srcdir = @top_srcdir@
|
|||
top_builddir = @top_builddir@
|
||||
|
||||
CPP_TEST_CASES = \
|
||||
li_boost_shared_ptr_director \
|
||||
li_cstring \
|
||||
li_factory \
|
||||
li_std_functors \
|
||||
li_std_list \
|
||||
li_std_multimap \
|
||||
li_std_pair_lang_object \
|
||||
li_std_queue \
|
||||
li_std_set \
|
||||
li_std_stack \
|
||||
li_std_wstring \
|
||||
primitive_types \
|
||||
ruby_keywords \
|
||||
ruby_minherit_shared_ptr \
|
||||
ruby_naming \
|
||||
ruby_track_objects \
|
||||
ruby_track_objects_directors \
|
||||
std_containers
|
||||
# ruby_li_std_speed
|
||||
# stl_new
|
||||
std_containers \
|
||||
# ruby_li_std_speed \
|
||||
# stl_new \
|
||||
|
||||
CPP11_TEST_CASES = \
|
||||
cpp11_hash_tables \
|
||||
cpp11_shared_ptr_const \
|
||||
cpp11_shared_ptr_nullptr_in_containers \
|
||||
cpp11_shared_ptr_upcast \
|
||||
cpp11_std_unordered_map \
|
||||
cpp11_std_unordered_multimap \
|
||||
cpp11_std_unordered_multiset \
|
||||
cpp11_std_unordered_set \
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cstring \
|
||||
|
|
|
|||
61
Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
Normal file
61
Examples/test-suite/ruby/cpp11_hash_tables_runme.rb
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
require 'swig_assert'
|
||||
require 'cpp11_hash_tables'
|
||||
|
||||
[Cpp11_hash_tables::MapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
|
||||
|
||||
swig_assert_equal("x.find_all{|e,k| e == 1}", "[[1,7]]", binding)
|
||||
|
||||
swig_assert_equal("x[1]", "7", binding)
|
||||
swig_assert_equal("x[2]", "nil", binding)
|
||||
x[2] = 9
|
||||
swig_assert_equal("x[2]", "9", binding)
|
||||
x.delete(2)
|
||||
swig_assert_equal("x[2]", "nil", binding)
|
||||
swig_assert_equal("x.empty?", "false", binding)
|
||||
x.delete(1)
|
||||
swig_assert_equal("x.empty?", "true", binding)
|
||||
swig_assert_equal("x.include?(1)", "false", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::MultiMapIntInt.new({1=>7}),
|
||||
Cpp11_hash_tables::UnorderedMultiMapIntInt.new({1=>7})].each{|x|
|
||||
x[1] = 9
|
||||
swig_assert_equal("x[1].sort", "[7,9]", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::SetInt.new([1]),
|
||||
Cpp11_hash_tables::MultiSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
|
||||
|
||||
swig_assert_equal("x.find_all{|e| e == 1}", "[1]", binding)
|
||||
|
||||
swig_assert_equal("x.include?(1)", "true", binding)
|
||||
swig_assert_equal("x.include?(2)", "false", binding)
|
||||
x << 2
|
||||
swig_assert_equal("x.include?(2)", "true", binding)
|
||||
x.erase(2)
|
||||
swig_assert_equal("x.empty?", "false", binding)
|
||||
x.erase(1)
|
||||
swig_assert_equal("x.empty?", "true", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::MultiSetInt.new([1]),
|
||||
Cpp11_hash_tables::UnorderedMultiSetInt.new([1])].each{|x|
|
||||
x << 1
|
||||
swig_assert_equal("x.count(1)", "2", binding)
|
||||
}
|
||||
|
||||
[Cpp11_hash_tables::MapIntInt,
|
||||
Cpp11_hash_tables::MultiMapIntInt,
|
||||
Cpp11_hash_tables::UnorderedMapIntInt,
|
||||
Cpp11_hash_tables::UnorderedMultiMapIntInt,
|
||||
Cpp11_hash_tables::SetInt,
|
||||
Cpp11_hash_tables::MultiSetInt,
|
||||
Cpp11_hash_tables::UnorderedSetInt,
|
||||
Cpp11_hash_tables::UnorderedMultiSetInt].each{|k|
|
||||
swig_assert("k.include?(Enumerable)", binding)
|
||||
}
|
||||
9
Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb
Normal file
9
Examples/test-suite/ruby/cpp11_shared_ptr_const_runme.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
require "swig_assert"
|
||||
require "cpp11_shared_ptr_const"
|
||||
|
||||
include Cpp11_shared_ptr_const
|
||||
|
||||
swig_assert_equal_simple(1, foo( Foo.new(1) ).get_m )
|
||||
swig_assert_equal_simple(7, const_foo( Foo.new(7) ).get_m )
|
||||
swig_assert_equal_simple(7, foo_vec( Foo.new(7) )[0].get_m )
|
||||
swig_assert_equal_simple(8, const_foo_vec( Foo.new(8) )[0].get_m )
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
require "cpp11_shared_ptr_nullptr_in_containers"
|
||||
|
||||
include Cpp11_shared_ptr_nullptr_in_containers
|
||||
|
||||
a = ret_vec_c_shared_ptr()
|
||||
raise unless a[0].get_m == 0
|
||||
raise unless a[1] == nil
|
||||
raise unless a[2].get_m == 2
|
||||
|
||||
a = ret_arg_vec([C.new(7), nil, C.new(9)])
|
||||
raise unless a[0].get_m == 7
|
||||
raise unless a[1] == nil
|
||||
raise unless a[2].get_m == 9
|
||||
|
||||
raise unless is_last_null([C.new(7), C.new(8), nil])
|
||||
raise if is_last_null([C.new(7), C.new(8)])
|
||||
60
Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb
Normal file
60
Examples/test-suite/ruby/cpp11_shared_ptr_upcast_runme.rb
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
require 'swig_assert'
|
||||
require 'cpp11_shared_ptr_upcast'
|
||||
|
||||
|
||||
include Cpp11_shared_ptr_upcast
|
||||
|
||||
# non-overloaded
|
||||
swig_assert_equal_simple( 7, derived_num1(Derived.new(7)) )
|
||||
swig_assert_equal_simple( 7, derived_num2([Derived.new(7)]) )
|
||||
swig_assert_equal_simple( 7, derived_num3({0 => Derived.new(7)}) )
|
||||
|
||||
swig_assert_equal_simple(-1, base_num1(Derived.new(7)) )
|
||||
swig_assert_equal_simple(-1, base_num2([Derived.new(7)]) )
|
||||
swig_assert_equal_simple(-1, base_num3({0 => Derived.new(7)}) )
|
||||
|
||||
swig_assert_equal_simple( 999, derived_num1(nil) )
|
||||
swig_assert_equal_simple( 999, derived_num2([nil]) )
|
||||
swig_assert_equal_simple( 999, derived_num3({0 => nil}) )
|
||||
|
||||
swig_assert_equal_simple( 999, base_num1(nil) )
|
||||
swig_assert_equal_simple( 999, base_num2([nil]) )
|
||||
swig_assert_equal_simple( 999, base_num3({0 => nil}) )
|
||||
|
||||
# overloaded
|
||||
swig_assert_equal_simple( 7, derived_num(Derived.new(7)) )
|
||||
swig_assert_equal_simple( 7, derived_num([Derived.new(7)]) )
|
||||
swig_assert_equal_simple( 7, derived_num({0 => Derived.new(7)}) )
|
||||
|
||||
swig_assert_equal_simple(-1, base_num(Derived.new(7)) )
|
||||
swig_assert_equal_simple(-1, base_num([Derived.new(7)]) )
|
||||
swig_assert_equal_simple(-1, base_num({0 => Derived.new(7)}) )
|
||||
|
||||
# ptr to shared_ptr
|
||||
swig_assert_equal_simple( 7, derived2_num1(Derived2.new(7)) )
|
||||
swig_assert_equal_simple( 7, derived2_num2([Derived2.new(7)]) )
|
||||
swig_assert_equal_simple( 7, derived2_num3({0 => Derived2.new(7)}) )
|
||||
|
||||
swig_assert_equal_simple( -1, base2_num1(Derived2.new(7)) )
|
||||
|
||||
begin
|
||||
# Upcast for pointers to shared_ptr in this generic framework has not been implemented
|
||||
swig_assert_equal_simple( -1, base2_num2([Derived2.new(7)]) )
|
||||
raise RuntimeError, "Failed to catch TypeError"
|
||||
rescue TypeError
|
||||
end
|
||||
begin
|
||||
# Upcast for pointers to shared_ptr in this generic framework has not been implemented
|
||||
swig_assert_equal_simple( -1, base2_num3({0 => Derived2.new(7)}) )
|
||||
raise RuntimeError, "Failed to catch TypeError"
|
||||
rescue TypeError
|
||||
end
|
||||
|
||||
swig_assert_equal_simple( 888, derived2_num1(nil) )
|
||||
swig_assert_equal_simple( 999, derived2_num2([nil]) ) # although 888 would be more consistent
|
||||
swig_assert_equal_simple( 999, derived2_num3({0 => nil}) ) # although 888 would be more consistent
|
||||
|
||||
swig_assert_equal_simple( 888, base2_num1(nil) )
|
||||
swig_assert_equal_simple( 999, base2_num2([nil]) ) # although 888 would be more consistent
|
||||
swig_assert_equal_simple( 999, base2_num3({0 => nil}) ) # although 888 would be more consistent
|
||||
|
||||
|
|
@ -30,6 +30,25 @@ class Director_smartptr_MyBarFoo < Foo
|
|||
end
|
||||
end
|
||||
|
||||
class Director_smartptr_MyBarFooDerived < FooDerived
|
||||
|
||||
def ping()
|
||||
return "director_smartptr_MyBarFooDerived.ping()"
|
||||
end
|
||||
|
||||
def pong()
|
||||
return "director_smartptr_MyBarFooDerived.pong();" + ping()
|
||||
end
|
||||
|
||||
def upcall(fooBarPtr)
|
||||
return "overrideDerived;" + fooBarPtr.FooBarDo()
|
||||
end
|
||||
|
||||
def makeFoo()
|
||||
return Foo.new()
|
||||
end
|
||||
end
|
||||
|
||||
def check(got, expected)
|
||||
if (got != expected)
|
||||
raise RuntimeError, "Failed, got: #{got} expected: #{expected}"
|
||||
|
|
@ -52,3 +71,8 @@ myFoo2 = Foo.new().makeFoo()
|
|||
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
|
||||
check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()")
|
||||
|
||||
myBarFooDerived = Director_smartptr_MyBarFooDerived.new()
|
||||
check(myBarFooDerived.ping(), "director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callPong(myBarFooDerived), "director_smartptr_MyBarFooDerived.pong();director_smartptr_MyBarFooDerived.ping()")
|
||||
check(FooDerived.callUpcall(myBarFooDerived, fooBar), "overrideDerived;Bar::Foo2::Foo2Bar()")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,79 @@
|
|||
require 'li_boost_shared_ptr_director'
|
||||
|
||||
include Li_boost_shared_ptr_director
|
||||
|
||||
class Derived < Base
|
||||
|
||||
def initialize(flag)
|
||||
@return_none = flag
|
||||
super()
|
||||
end
|
||||
|
||||
def ret_c_shared_ptr
|
||||
if @return_none
|
||||
nil
|
||||
else
|
||||
C.new
|
||||
end
|
||||
end
|
||||
|
||||
def ret_c_by_value
|
||||
C.new
|
||||
end
|
||||
|
||||
def take_c_by_value(c)
|
||||
c.get_m
|
||||
end
|
||||
|
||||
def take_c_shared_ptr_by_value(c)
|
||||
if c
|
||||
c.get_m
|
||||
else
|
||||
-2
|
||||
end
|
||||
end
|
||||
|
||||
def take_c_shared_ptr_by_ref(c)
|
||||
if c
|
||||
c.get_m
|
||||
else
|
||||
-3
|
||||
end
|
||||
end
|
||||
|
||||
def take_c_shared_ptr_by_pointer(c)
|
||||
if c
|
||||
c.get_m
|
||||
else
|
||||
-4
|
||||
end
|
||||
end
|
||||
|
||||
def take_c_shared_ptr_by_pointer_ref(c)
|
||||
if c
|
||||
c.get_m
|
||||
else
|
||||
-5
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
a = Derived.new(false)
|
||||
b = Derived.new(true)
|
||||
|
||||
raise unless call_ret_c_shared_ptr(a) == 1
|
||||
raise unless call_ret_c_shared_ptr(b) == -1
|
||||
raise unless call_ret_c_by_value(a) == 1
|
||||
|
||||
raise unless call_take_c_by_value(a) == 5
|
||||
raise unless call_take_c_shared_ptr_by_value(a) == 6
|
||||
raise unless call_take_c_shared_ptr_by_ref(a) == 7
|
||||
raise unless call_take_c_shared_ptr_by_pointer(a) == 8
|
||||
raise unless call_take_c_shared_ptr_by_pointer_ref(a) == 9
|
||||
|
||||
raise unless call_take_c_shared_ptr_by_value_with_null(a) == -2
|
||||
raise unless call_take_c_shared_ptr_by_ref_with_null(a) == -3
|
||||
raise unless call_take_c_shared_ptr_by_pointer_with_null(a) == -4
|
||||
raise unless call_take_c_shared_ptr_by_pointer_ref_with_null(a) == -5
|
||||
|
||||
8
Examples/test-suite/ruby/li_std_list_runme.rb
Normal file
8
Examples/test-suite/ruby/li_std_list_runme.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
require 'swig_assert'
|
||||
|
||||
require 'li_std_list'
|
||||
|
||||
include Li_std_list
|
||||
|
||||
x = DoubleList.new([1,2,3])
|
||||
swig_assert_equal("[1.0]", "x.find_all{|e| e == 1 }", binding)
|
||||
42
Examples/test-suite/ruby/li_std_wstring_runme.rb
Normal file
42
Examples/test-suite/ruby/li_std_wstring_runme.rb
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
require 'swig_assert'
|
||||
require 'li_std_wstring'
|
||||
|
||||
x = "abc"
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_value(Li_std_wstring::Wstring.new(x))", "x", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload()", "nil", binding)
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_reference(Li_std_wstring::Wstring.new(x))", "nil", binding)
|
||||
|
||||
x = "y"
|
||||
swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
|
||||
a = Li_std_wstring::A.new(x)
|
||||
swig_assert_equal("Li_std_wstring.test_value(a)", "x", binding)
|
||||
|
||||
x = "hello"
|
||||
swig_assert_equal("Li_std_wstring.test_const_reference(x)", "x", binding)
|
||||
|
||||
|
||||
swig_assert_equal("Li_std_wstring.test_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_const_pointer_out", "'x'", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_reference_out()", "'x'", binding)
|
||||
|
||||
s = "abc"
|
||||
swig_assert("Li_std_wstring.test_equal_abc(s)", binding)
|
||||
|
||||
begin
|
||||
Li_std_wstring.test_throw
|
||||
rescue RuntimeError => e
|
||||
swig_assert_equal("e.message", "'x'", binding)
|
||||
end
|
||||
|
||||
x = "abc\0def"
|
||||
swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
|
||||
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", '"abc"', binding)
|
||||
swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", '"abc"', binding)
|
||||
|
|
@ -13,6 +13,8 @@ require 'swig_assert'
|
|||
require 'std_containers'
|
||||
include Std_containers
|
||||
|
||||
swig_assert_equal("[true, false]", "videntb([true, false])")
|
||||
|
||||
swig_assert_each_line(<<'EOF', binding)
|
||||
|
||||
cube = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# A simple function to create useful asserts
|
||||
# Useful assert functions
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Exception raised when some swig binding test fails
|
||||
|
|
@ -15,6 +10,21 @@ class SwigRubyError < RuntimeError
|
|||
end
|
||||
|
||||
|
||||
#
|
||||
# Simple assertions. Strings are not needed as arguments.
|
||||
#
|
||||
def swig_assert_equal_simple(a, b)
|
||||
unless a == b
|
||||
raise SwigRubyError.new("\n#{a} expected but was \n#{b}")
|
||||
end
|
||||
end
|
||||
|
||||
def swig_assert_simple(a)
|
||||
unless a
|
||||
raise SwigRubyError.new("assertion falied.")
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Asserts whether a and b are equal.
|
||||
#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue