From dbb0c18d3e71290433ec39abb65053c70b38ae0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Oct 2004 21:07:53 +0000 Subject: [PATCH] runtime tests for templated functions in a namespace added (overloading and default arg tests) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6456 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/overload_template_runme.java | 30 +++++++++++++ .../java/template_default_arg_runme.java | 42 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/Examples/test-suite/java/overload_template_runme.java b/Examples/test-suite/java/overload_template_runme.java index 435175981..e76bf63ee 100644 --- a/Examples/test-suite/java/overload_template_runme.java +++ b/Examples/test-suite/java/overload_template_runme.java @@ -96,6 +96,7 @@ public class overload_template_runme { overload_template.xyz_int(); overload_template.xyz_double(); + // a bit of everything if (overload_template.overload("hi") != 0) throw new RuntimeException ("overload()"); @@ -125,6 +126,35 @@ public class overload_template_runme { if (overload_template.overload() != 50) throw new RuntimeException ("overload(const char *)"); + + // everything put in a namespace + if (overload_template.nsoverload("hi") != 1000) + throw new RuntimeException ("nsoverload()"); + + if (overload_template.nsoverload(1) != 1010) + throw new RuntimeException ("nsoverload(int t)"); + + if (overload_template.nsoverload(1, 1) != 1020) + throw new RuntimeException ("nsoverload(int t, const int &)"); + + if (overload_template.nsoverload(1, "hello") != 1030) + throw new RuntimeException ("nsoverload(int t, const char *)"); + + if (overload_template.nsoverload(k) != 1010) + throw new RuntimeException ("nsoverload(Klass t)"); + + if (overload_template.nsoverload(k, k) != 1020) + throw new RuntimeException ("nsoverload(Klass t, const Klass &)"); + + if (overload_template.nsoverload(k, "hello") != 1030) + throw new RuntimeException ("nsoverload(Klass t, const char *)"); + + if (overload_template.nsoverload(10.0, "hi") != 1040) + throw new RuntimeException ("nsoverload(double t, const char *)"); + + if (overload_template.nsoverload() != 1050) + throw new RuntimeException ("nsoverload(const char *)"); + } } diff --git a/Examples/test-suite/java/template_default_arg_runme.java b/Examples/test-suite/java/template_default_arg_runme.java index 7f59cc57e..b274935da 100644 --- a/Examples/test-suite/java/template_default_arg_runme.java +++ b/Examples/test-suite/java/template_default_arg_runme.java @@ -107,7 +107,49 @@ public class template_default_arg_runme { if (template_default_arg.ott(new Hello_int()) != 60) throw new RuntimeException("ott test 13 failed"); + } + // Above test in namespaces + { + // plain function: int nsott(Foo) + if (template_default_arg.nsott(new Foo_int()) != 130) + throw new RuntimeException("nsott test 1 failed"); + + // %template(nsott) nsott; + if (template_default_arg.nsott() != 110) + throw new RuntimeException("nsott test 2 failed"); + if (template_default_arg.nsott(1) != 110) + throw new RuntimeException("nsott test 3 failed"); + if (template_default_arg.nsott(1, 1) != 110) + throw new RuntimeException("nsott test 4 failed"); + + if (template_default_arg.nsott("hi") != 120) + throw new RuntimeException("nsott test 5 failed"); + if (template_default_arg.nsott("hi", 1) != 120) + throw new RuntimeException("nsott test 6 failed"); + if (template_default_arg.nsott("hi", 1, 1) != 120) + throw new RuntimeException("nsott test 7 failed"); + + // %template(nsott) nsott; + if (template_default_arg.nsottstring(new Hello_int(), "hi") != 140) + throw new RuntimeException("nsott test 8 failed"); + + if (template_default_arg.nsottstring(new Hello_int()) != 140) + throw new RuntimeException("nsott test 9 failed"); + + // %template(nsott) nsott; + if (template_default_arg.nsottint(new Hello_int(), 1) != 150) + throw new RuntimeException("nsott test 10 failed"); + + if (template_default_arg.nsottint(new Hello_int()) != 150) + throw new RuntimeException("nsott test 11 failed"); + + // %template(nsott) nsott; + if (template_default_arg.nsott(new Hello_int(), 1.0) != 160) + throw new RuntimeException("nsott test 12 failed"); + + if (template_default_arg.nsott(new Hello_int()) != 160) + throw new RuntimeException("nsott test 13 failed"); } } }