summaryrefslogtreecommitdiff
path: root/Examples/test-suite/java
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/java')
-rw-r--r--Examples/test-suite/java/Makefile.in4
-rw-r--r--Examples/test-suite/java/char_binary_runme.java24
-rw-r--r--Examples/test-suite/java/director_protected_runme.java32
-rw-r--r--Examples/test-suite/java/global_namespace_runme.java34
-rw-r--r--Examples/test-suite/java/pointer_reference_runme.java3
-rw-r--r--Examples/test-suite/java/preproc_line_file_runme.java68
-rw-r--r--Examples/test-suite/java/rename_pcre_encoder_runme.java14
-rw-r--r--Examples/test-suite/java/rename_pcre_enum_runme.java26
-rw-r--r--Examples/test-suite/java/rname_runme.java2
-rw-r--r--Examples/test-suite/java/smart_pointer_const_overload_runme.java99
-rw-r--r--Examples/test-suite/java/typemap_arrays_runme.java19
-rw-r--r--Examples/test-suite/java/wallkw_runme.java4
12 files changed, 322 insertions, 7 deletions
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index ba225f6e9..1ba888fc1 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -7,8 +7,8 @@ JAVA = java
JAVAC = javac
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
-top_srcdir = @top_srcdir@/..
-top_builddir = @top_builddir@/..
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
C_TEST_CASES = \
java_lib_arrays \
diff --git a/Examples/test-suite/java/char_binary_runme.java b/Examples/test-suite/java/char_binary_runme.java
new file mode 100644
index 000000000..9227f8617
--- /dev/null
+++ b/Examples/test-suite/java/char_binary_runme.java
@@ -0,0 +1,24 @@
+import char_binary.*;
+
+public class char_binary_runme {
+
+ static {
+ try {
+ System.loadLibrary("char_binary");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Test t = new Test();
+ byte[] hile = "hile".getBytes();
+ byte[] hil0 = "hil\0".getBytes();
+ if (t.strlen(hile) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+
+ if (t.strlen(hil0) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+ }
+}
diff --git a/Examples/test-suite/java/director_protected_runme.java b/Examples/test-suite/java/director_protected_runme.java
index 464b4d4d9..63ac03502 100644
--- a/Examples/test-suite/java/director_protected_runme.java
+++ b/Examples/test-suite/java/director_protected_runme.java
@@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
+ director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
+ method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Bar::cheer should be protected" );
+
+ method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Foo::cheer should be protected" );
+
} catch (NoSuchMethodException n) {
- throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
+
+ if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3::cheer");
+
+ if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callping");
+
+ if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callcheer");
+
+ if (!fb3.callping().equals("Bar::ping();"))
+ throw new RuntimeException("bad fb3.callping");
+
+ if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3.callcheer");
}
}
@@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
+class director_protected_FooBar3 extends Bar {
+ public String cheer() {
+ return "director_protected_FooBar3::cheer();";
+ }
+}
+
diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java
index faab7d4ba..205e149b0 100644
--- a/Examples/test-suite/java/global_namespace_runme.java
+++ b/Examples/test-suite/java/global_namespace_runme.java
@@ -13,8 +13,38 @@ public class global_namespace_runme {
public static void main(String argv[]) {
- KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
- KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+ Klass1 k1 = new Klass1();
+ Klass2 k2 = new Klass2();
+ Klass3 k3 = new Klass3();
+ Klass4 k4 = new Klass4();
+ Klass5 k5 = new Klass5();
+ Klass6 k6 = new Klass6();
+ Klass7 k7 = new Klass7();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1A();
+ k2 = global_namespace.getKlass2A();
+ k3 = global_namespace.getKlass3A();
+ k4 = global_namespace.getKlass4A();
+ k5 = global_namespace.getKlass5A();
+ k6 = global_namespace.getKlass6A();
+ k7 = global_namespace.getKlass7A();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1B();
+ k2 = global_namespace.getKlass2B();
+ k3 = global_namespace.getKlass3B();
+ k4 = global_namespace.getKlass4B();
+ k5 = global_namespace.getKlass5B();
+ k6 = global_namespace.getKlass6B();
+ k7 = global_namespace.getKlass7B();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
diff --git a/Examples/test-suite/java/pointer_reference_runme.java b/Examples/test-suite/java/pointer_reference_runme.java
index e8bd6800e..284951611 100644
--- a/Examples/test-suite/java/pointer_reference_runme.java
+++ b/Examples/test-suite/java/pointer_reference_runme.java
@@ -19,5 +19,8 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.getInstance().getValue() != 20) throw new RuntimeException("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new RuntimeException("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new RuntimeException("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
new file mode 100644
index 000000000..c29cef680
--- /dev/null
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -0,0 +1,68 @@
+import preproc_line_file.*;
+
+public class preproc_line_file_runme {
+
+ static {
+ try {
+ System.loadLibrary("preproc_line_file");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static String FILENAME_WINDOWS = "..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i";
+ public static String FILENAME_UNIX = "../../../../Examples/test-suite/preproc_line_file.i";
+ public static void main(String argv[]) throws Throwable
+ {
+ int myline = preproc_line_file.MYLINE;
+ int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED;
+ if (myline != 4)
+ throw new RuntimeException("preproc failure");
+ if (myline + 100 + 1 != myline_adjusted)
+ throw new RuntimeException("preproc failure");
+
+ String myfile = preproc_line_file.MYFILE;
+ String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
+ if (!(myfile.equals(FILENAME_UNIX) || myfile.equals(FILENAME_WINDOWS)))
+ throw new RuntimeException("preproc failure");
+
+ if (!(myfile_adjusted.equals(FILENAME_UNIX + ".bak") || myfile_adjusted.equals(FILENAME_WINDOWS + ".bak")))
+ throw new RuntimeException("preproc failure");
+
+ if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_A");
+
+ if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_B");
+
+ if (preproc_line_file.getThing27() != -1)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.getThing28() != -2)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.MYLINE2 != 30)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyStruct.LINE_NUMBER != 52)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyMacroClass.LINE_NUM != 56)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyMultipleMacroStruct.LINE_NUM != 81)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.INLINE_LINE != 87)
+ throw new RuntimeException("preproc failure");
+
+ String inlineFile = preproc_line_file.INLINE_FILE;
+ if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS)))
+ throw new RuntimeException("preproc failure");
+
+ if (Slash.LINE_NUM != 93)
+ throw new RuntimeException("preproc failure");
+
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java
new file mode 100644
index 000000000..cb843338b
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java
@@ -0,0 +1,14 @@
+import rename_pcre_encoder.*;
+
+public class rename_pcre_encoder_runme {
+ static { System.loadLibrary("rename_pcre_encoder"); }
+
+ public static void main(String argv[])
+ {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new RuntimeException(String.format("Border with should be 17, not %d",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_enum_runme.java b/Examples/test-suite/java/rename_pcre_enum_runme.java
new file mode 100644
index 000000000..a8bfef46a
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_enum_runme.java
@@ -0,0 +1,26 @@
+import rename_pcre_enum.*;
+
+public class rename_pcre_enum_runme {
+ static { System.loadLibrary("rename_pcre_enum"); }
+
+ public static void main(String argv[])
+ {
+ Foo foo = Foo.First;
+ if ( foo == Foo.Second )
+ throw new RuntimeException("Enum values should be different");
+
+ // Check that Foo_Max enum element was ignored.
+ int numFooEnumElements = Foo.values().length;
+ if ( numFooEnumElements != 2 )
+ throw new RuntimeException(String.format("Enum should have 2 elements, not %d",
+ numFooEnumElements));
+
+ BoundaryCondition bc = BoundaryCondition.MaxMax;
+ if ( bc.ordinal() != 2 )
+ throw new RuntimeException("Wrong enum value");
+
+ Colour c = Colour.red;
+ if ( c == Colour.blue )
+ throw new RuntimeException("Enum values should be different");
+ }
+}
diff --git a/Examples/test-suite/java/rname_runme.java b/Examples/test-suite/java/rname_runme.java
index 7f2ab2f75..dac0a1ecf 100644
--- a/Examples/test-suite/java/rname_runme.java
+++ b/Examples/test-suite/java/rname_runme.java
@@ -30,7 +30,7 @@ public class rname_runme {
throw new RuntimeException("base.newname");
RenamedDerived derived = new RenamedDerived();
- derived.func(base, base, base);
+ derived.Xfunc(base, base, base);
if (!derived.newname(10.0).equals("Derived"))
throw new RuntimeException("derived.newname");
}
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
new file mode 100644
index 000000000..bb4ae2c8f
--- /dev/null
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -0,0 +1,99 @@
+import smart_pointer_const_overload.*;
+
+public class smart_pointer_const_overload_runme {
+ static int CONST_ACCESS = 1;
+ static int MUTABLE_ACCESS = 2;
+
+ static {
+ System.loadLibrary("smart_pointer_const_overload");
+ }
+
+ public static void test(Bar b, Foo f) {
+ Assert(f.getX() == 0);
+
+ // Test member variable get
+ Assert(b.getX() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test member variable set
+ b.setX(1);
+ Assert(f.getX() == 1);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test const method
+ Assert(b.getx() == 1);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test mutable method
+ b.setx(2);
+
+ Assert(f.getX() == 2);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test extended const method
+ Assert(b.getx2() == 2);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test extended mutable method
+ b.setx2(3);
+
+ Assert(f.getX() == 3);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test static method
+ b.stat();
+
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(b.getY() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through mutable pointer to const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through const pointer to mutable member
+ f.setX(4);
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set through const pointer to mutable member
+ f.setAccess(MUTABLE_ACCESS);
+ smart_pointer_const_overload.set_int(b.getXp(), 5);
+
+ Assert(f.getX() == 5);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set pointer to const member
+ b.setYp(smart_pointer_const_overload.new_int(6));
+
+ Assert(f.getY() == 0);
+ Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ smart_pointer_const_overload.delete_int(f.getYp());
+ }
+
+ public static void main(String argv[]) {
+ Foo f = new Foo();
+ Bar b = new Bar(f);
+
+ //Foo f2 = new Foo();
+ //Bar b2 = new Bar2(f2);
+
+ test(b, f);
+ //test(b2, f2);
+ }
+
+ public static void Assert(boolean b) {
+ if (!b)
+ throw new RuntimeException("Assertion failed");
+ }
+}
diff --git a/Examples/test-suite/java/typemap_arrays_runme.java b/Examples/test-suite/java/typemap_arrays_runme.java
new file mode 100644
index 000000000..1ca062f78
--- /dev/null
+++ b/Examples/test-suite/java/typemap_arrays_runme.java
@@ -0,0 +1,19 @@
+import typemap_arrays.*;
+
+public class typemap_arrays_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_arrays");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ if (typemap_arrays.sumA(null) != 60)
+ throw new RuntimeException("Sum is wrong");
+ }
+}
+
diff --git a/Examples/test-suite/java/wallkw_runme.java b/Examples/test-suite/java/wallkw_runme.java
index 028c2a32f..7695cda24 100644
--- a/Examples/test-suite/java/wallkw_runme.java
+++ b/Examples/test-suite/java/wallkw_runme.java
@@ -19,7 +19,9 @@ public class wallkw_runme {
throw new RuntimeException("delegate keyword fail");
if (!wallkw._pass().equals("pass"))
throw new RuntimeException("pass keyword fail");
- if (!wallkw.C_alias().equals("alias"))
+ if (!wallkw._alias().equals("alias"))
throw new RuntimeException("alias keyword fail");
+ if (!wallkw.C_rescue().equals("rescue"))
+ throw new RuntimeException("rescue keyword fail");
}
}