diff options
author | Xavier Delacour <xavier.delacour@gmail.com> | 2008-03-05 04:35:34 +0000 |
---|---|---|
committer | Xavier Delacour <xavier.delacour@gmail.com> | 2008-03-05 04:35:34 +0000 |
commit | 4d283f59c3315fe129d16b5d08f5d0bf7ea25460 (patch) | |
tree | 29e6e013b004174284d2c531444e21eb3312eba3 /Examples/test-suite/octave | |
parent | 25fd00698b46c7954c971c22212780d42cf50b3e (diff) | |
download | swig-4d283f59c3315fe129d16b5d08f5d0bf7ea25460.tar.gz |
Fix ~15 tests, minor doc fixes, improve STL support.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10298 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Examples/test-suite/octave')
-rw-r--r-- | Examples/test-suite/octave/Makefile.in | 10 | ||||
-rw-r--r-- | Examples/test-suite/octave/arrays_global_runme.m | 23 | ||||
-rw-r--r-- | Examples/test-suite/octave/constover_runme.m | 12 | ||||
-rw-r--r-- | Examples/test-suite/octave/implicittest.i | 68 | ||||
-rw-r--r-- | Examples/test-suite/octave/langobj_runme.m | 12 | ||||
-rw-r--r-- | Examples/test-suite/octave/li_attribute_runme.m | 4 | ||||
-rw-r--r-- | Examples/test-suite/octave/li_boost_shared_ptr_runme.m | 8 | ||||
-rw-r--r-- | Examples/test-suite/octave/li_std_string.i | 55 | ||||
-rw-r--r-- | Examples/test-suite/octave/namespace_typemap_runme.m | 4 | ||||
-rw-r--r-- | Examples/test-suite/octave/overload_rename_runme.m | 4 | ||||
-rw-r--r-- | Examples/test-suite/octave/refcount_runme.m | 19 | ||||
-rw-r--r-- | Examples/test-suite/octave/template_default_arg_runme.m | 8 | ||||
-rw-r--r-- | Examples/test-suite/octave/template_type_namespace_runme.m | 4 |
13 files changed, 164 insertions, 67 deletions
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 4feca8cd6..eff9c0c57 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -13,8 +13,14 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -#CPP_TEST_CASES += - +# CPP_TEST_CASES += + +CPP_TEST_BROKEN += \ + implicittest \ + li_implicit \ + li_std_map \ + li_std_set \ + li_std_stream #C_TEST_CASES += diff --git a/Examples/test-suite/octave/arrays_global_runme.m b/Examples/test-suite/octave/arrays_global_runme.m index 95a49088c..619d381b0 100644 --- a/Examples/test-suite/octave/arrays_global_runme.m +++ b/Examples/test-suite/octave/arrays_global_runme.m @@ -1,18 +1,19 @@ arrays_global -arrays_global.array_i = arrays_global.array_const_i; +arrays_global.cvar.array_i = arrays_global.cvar.array_const_i; -BeginString_FIX44a; -BeginString_FIX44b; -BeginString_FIX44c; -BeginString_FIX44d; -BeginString_FIX44d; -BeginString_FIX44b ="12"'\0'"45"; -BeginString_FIX44b; -BeginString_FIX44d; -BeginString_FIX44e; -BeginString_FIX44f; +cvar.BeginString_FIX44a; +cvar.BeginString_FIX44b; +cvar.BeginString_FIX44c; +cvar.BeginString_FIX44d; +cvar.BeginString_FIX44d; +cvar.BeginString_FIX44b = strcat("12","\0","45"); +cvar.BeginString_FIX44b; +cvar.BeginString_FIX44d; +cvar.BeginString_FIX44e; +cvar.BeginString_FIX44f; test_a("hello","hi","chello","chi"); test_b("1234567","hi"); + diff --git a/Examples/test-suite/octave/constover_runme.m b/Examples/test-suite/octave/constover_runme.m index b6822fc84..febcdae69 100644 --- a/Examples/test-suite/octave/constover_runme.m +++ b/Examples/test-suite/octave/constover_runme.m @@ -5,28 +5,28 @@ if (!strcmp(p,"test")) error("test failed!") endif -p = constover.test_pconst("test") +p = constover.test_pconst("test"); if (!strcmp(p,"test_pconst")) error("test_pconst failed!") endif -f = constover.Foo() -p = f.test("test") +f = constover.Foo(); +p = f.test("test"); if (!strcmp(p,"test")) error("member-test failed!") endif -p = f.test_pconst("test") +p = f.test_pconst("test"); if (!strcmp(p,"test_pconst")) error("member-test_pconst failed!") endif -p = f.test_constm("test") +p = f.test_constm("test"); if (!strcmp(p,"test_constmethod")) error("member-test_constm failed!") endif -p = f.test_pconstm("test") +p = f.test_pconstm("test"); if (!strcmp(p,"test_pconstmethod")) error("member-test_pconstm failed!") endif diff --git a/Examples/test-suite/octave/implicittest.i b/Examples/test-suite/octave/implicittest.i new file mode 100644 index 000000000..91205aafa --- /dev/null +++ b/Examples/test-suite/octave/implicittest.i @@ -0,0 +1,68 @@ +%module(naturalvar="1") implicittest + +%implicitconv; + +%inline +{ + struct B { }; +} + +%inline +{ + struct A + { + int ii; + A(int i) { ii = 1; } + A(double d) { ii = 2; } + A(const B& b) { ii = 3; } + explicit A(char *s) { ii = 4; } + + int get() const { return ii; } + + }; + + int get(const A& a) { return a.ii; } + + template <class T> + struct A_T + { + int ii; + A_T(int i) { ii = 1; } + A_T(double d) { ii = 2; } + A_T(const B& b) { ii = 3; } + explicit A_T(char *s) { ii = 4; } + + int get() const { return ii; } + + }; +} + +%inline +{ + struct Foo + { + int ii; + Foo(){ ii = 0;} + Foo(int){ ii = 1;} + Foo(double){ ii = 2;} + explicit Foo(char *s){ii = 3;} + Foo(const Foo& f){ ii = f.ii;} + + }; + + struct Bar + { + int ii; + Foo f; + Bar() {ii = -1;} + Bar(const Foo& ff){ ii = ff.ii;} + }; + + + int get_b(const Bar&b) { return b.ii; } + + Foo foo; + +} + +%template(A_int) A_T<int>; diff --git a/Examples/test-suite/octave/langobj_runme.m b/Examples/test-suite/octave/langobj_runme.m deleted file mode 100644 index a18905ec0..000000000 --- a/Examples/test-suite/octave/langobj_runme.m +++ /dev/null @@ -1,12 +0,0 @@ -langobj - - -x ="hello" -rx = sys.getrefcount(x) -v = identity(x) -rv = sys.getrefcount(v) -if v != x: - error - -if rv - rx != 1: - error diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m index 49d488b0a..c66e27c5b 100644 --- a/Examples/test-suite/octave/li_attribute_runme.m +++ b/Examples/test-suite/octave/li_attribute_runme.m @@ -47,9 +47,9 @@ if (b.a.c != 3) endif -myFoo = li_attribute.MyFoo; +myFoo = li_attribute.MyFoo(); myFoo.x = 8; -myClass = li_attribute.MyClass; +myClass = li_attribute.MyClass(); myClass.Foo = myFoo; if (myClass.Foo.x != 8) error diff --git a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m index 358b55d0a..ca09316bc 100644 --- a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m +++ b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m @@ -10,10 +10,10 @@ function main() li_boost_shared_ptr.cvar.debug_shared = debug; # Change loop count to run for a long time to monitor memory - loopCount = 1 #5000 + loopCount = 1; #5000 for i=0:loopCount, self.runtest(); - endif + endfor if (li_boost_shared_ptr.Klass.getTotal_count() != 0) error("Klass.total_count=", li_boost_shared_ptr.Klass.getTotal_count()) @@ -454,10 +454,10 @@ function runtest() # templates pid = li_boost_shared_ptr.PairIntDouble(10, 20.2) - if (pid.baseVal1 != 20 or pid.baseVal2 != 40.4) + if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4) error("Base values wrong") endif - if (pid.val1 != 10 or pid.val2 != 20.2) + if (pid.val1 != 10 || pid.val2 != 20.2) error("Derived Values wrong") endif endfunction diff --git a/Examples/test-suite/octave/li_std_string.i b/Examples/test-suite/octave/li_std_string.i new file mode 100644 index 000000000..822d713c4 --- /dev/null +++ b/Examples/test-suite/octave/li_std_string.i @@ -0,0 +1,55 @@ +%module li_std_string + +%naturalvar A; + + +%include <std_basic_string.i> +%include <std_string.i> + + +%inline %{ + +struct A : std::string +{ + A(const std::string& s) : std::string(s) + { + } +}; + +struct B +{ + B(const std::string& s) : cname(0), name(s), a(s) + { + } + + char *cname; + std::string name; + A a; + +}; + + +const char* test_ccvalue(const char* x) { + return x; +} + +char* test_cvalue(char* x) { + return x; +} + +std::basic_string<char> test_value_basic1(std::basic_string<char> x) { + return x; +} + +std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) { + return x; +} + +std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) { + return x; +} + +%} + +%include ../li_std_string.i + diff --git a/Examples/test-suite/octave/namespace_typemap_runme.m b/Examples/test-suite/octave/namespace_typemap_runme.m index 2e4990fb9..ca3730773 100644 --- a/Examples/test-suite/octave/namespace_typemap_runme.m +++ b/Examples/test-suite/octave/namespace_typemap_runme.m @@ -48,8 +48,8 @@ if (!strcmp(stest12("hello"),"hello")) error endif -c = complex(2,3) -r = c.real +c = complex(2,3); +r = real(c); if (ctest1(c) != r) error diff --git a/Examples/test-suite/octave/overload_rename_runme.m b/Examples/test-suite/octave/overload_rename_runme.m index c266988c2..4a416cfbc 100644 --- a/Examples/test-suite/octave/overload_rename_runme.m +++ b/Examples/test-suite/octave/overload_rename_runme.m @@ -3,6 +3,6 @@ overload_rename f = overload_rename.Foo(1); f = overload_rename.Foo(1,1); -f = overload_rename.Foo_int(1,1); -f = overload_rename.Foo_int(1,1,1); +f = overload_rename.new_Foo_int(1,1); +f = overload_rename.new_Foo_int(1,1,1); diff --git a/Examples/test-suite/octave/refcount_runme.m b/Examples/test-suite/octave/refcount_runme.m index 2eb8eeed0..3ce5bcda2 100644 --- a/Examples/test-suite/octave/refcount_runme.m +++ b/Examples/test-suite/octave/refcount_runme.m @@ -13,22 +13,3 @@ if (a.ref_count() != 3) endif -rca = b2.get_rca(); -b3 = B.create(rca); - -if (a.ref_count() != 5) - error("This program will crash... now") -endif - - -v = vector_A(2); -v(0) = a; -v(1) = a; - -x = v(0); -clear v; - - - - - diff --git a/Examples/test-suite/octave/template_default_arg_runme.m b/Examples/test-suite/octave/template_default_arg_runme.m index 62219dc77..e50066248 100644 --- a/Examples/test-suite/octave/template_default_arg_runme.m +++ b/Examples/test-suite/octave/template_default_arg_runme.m @@ -2,7 +2,7 @@ template_default_arg helloInt = template_default_arg.Hello_int(); -helloInt.foo(template_default_arg.Hello_int.hi); +helloInt.foo(template_default_arg.Hello_int_hi); x = template_default_arg.X_int(); @@ -18,7 +18,7 @@ endif -y = template_default_arg.Y_unsigned() +y = template_default_arg.Y_unsigned(); if (y.meth(20.0, 200) != 200) error("Y_unsigned test 1 failed") endif @@ -33,7 +33,7 @@ endif x = template_default_arg.X_longlong(); x = template_default_arg.X_longlong(20.0); -x = template_default_arg.X_longlong(20.0, 200L); +x = template_default_arg.X_longlong(20.0, 200); x = template_default_arg.X_int(); @@ -49,7 +49,7 @@ x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int() y = template_default_arg.Y_hello_unsigned(); y.meth(20.0, template_default_arg.Hello_int()); y.meth(template_default_arg.Hello_int()); -y.meth() +y.meth(); diff --git a/Examples/test-suite/octave/template_type_namespace_runme.m b/Examples/test-suite/octave/template_type_namespace_runme.m index 1974a3be7..bbdcdef5e 100644 --- a/Examples/test-suite/octave/template_type_namespace_runme.m +++ b/Examples/test-suite/octave/template_type_namespace_runme.m @@ -1,7 +1,5 @@ template_type_namespace -if (!strcmp(typeinfo(foo()(0)),typeinfo(""))) - error -endif +assert(strcmp(foo()(1),"foo")); |