Merge branch 'master' into gsoc2012-scilab
Conflicts: .gitignore .travis.yml COPYRIGHT Examples/Makefile.in Examples/test-suite/constructor_copy.i Makefile.in configure.ac
This commit is contained in:
commit
07b06a4089
30 changed files with 46894 additions and 11313 deletions
|
|
@ -7,6 +7,7 @@ JAVA = @JAVA@
|
|||
JAVAC = @JAVAC@
|
||||
JAVAFLAGS = -Xcheck:jni
|
||||
SCRIPTSUFFIX = _runme.java
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = ../@top_srcdir@
|
||||
top_builddir = ../@top_builddir@
|
||||
|
|
@ -24,6 +25,8 @@ CPP_TEST_CASES = \
|
|||
java_constants \
|
||||
java_director \
|
||||
java_director_assumeoverride \
|
||||
java_director_exception_feature \
|
||||
java_director_exception_feature_nspace \
|
||||
java_enums \
|
||||
java_jnitypes \
|
||||
java_lib_arrays_dimensionless \
|
||||
|
|
@ -40,19 +43,21 @@ CPP_TEST_CASES = \
|
|||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
SRCDIR = ../$(srcdir)/
|
||||
JAVA_PACKAGE = $*
|
||||
JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE)
|
||||
SWIGOPT += $(JAVA_PACKAGEOPT)
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
java_nspacewithoutpackage.%: JAVA_PACKAGEOPT =
|
||||
java_director_exception_feature_nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace.%: JAVA_PACKAGE = $*Package
|
||||
nspace_extend.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace.%: JAVA_PACKAGE = $*Package
|
||||
director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
%.cpptest:
|
||||
$(setup)
|
||||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_cpp))
|
||||
$(run_testcase)
|
||||
|
|
@ -62,17 +67,17 @@ director_nspace_director_name_collision.%: JAVA_PACKAGE = $*Package
|
|||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_c))
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+(cd $(JAVA_PACKAGE) && $(swig_and_compile_multi_cpp))
|
||||
$(run_testcase)
|
||||
|
||||
# Makes a directory for the testcase if it does not exist
|
||||
setup = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \
|
||||
else \
|
||||
echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
|
||||
echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \
|
||||
fi; \
|
||||
if [ ! -d $(JAVA_PACKAGE) ]; then \
|
||||
mkdir $(JAVA_PACKAGE); \
|
||||
|
|
@ -83,8 +88,8 @@ setup = \
|
|||
# Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X.
|
||||
run_testcase = \
|
||||
cd $(JAVA_PACKAGE) && $(COMPILETOOL) $(JAVAC) -classpath . `find . -name "*.java"` && cd .. && \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
env LD_LIBRARY_PATH="$(JAVA_PACKAGE):$$LD_LIBRARY_PATH" PATH="$(JAVA_PACKAGE):$$PATH" SHLIB_PATH="$(JAVA_PACKAGE):$$SHLIB_PATH" DYLD_LIBRARY_PATH="$(JAVA_PACKAGE):$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) $(JAVAFLAGS) -classpath . $*_runme; \
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
See ../README for common README file.
|
||||
|
||||
The Java implementation of the test-suite is a little different to the other languages in that all of SWIGs output goes into a subdirectory named after the individual test case. This is so that all the shadow classes can be compiled as Java classes have to go into separate files. Otherwise the Makefile wouldn't know which .java files would be relevant to the testcase. For this to work the testcase must go into a Java package.
|
||||
The Java implementation of the test-suite is a little different to the other languages in that all of SWIG's output goes into a subdirectory named after the individual test case. This is so that all the shadow classes can be compiled as Java classes which have to go into separate files. Otherwise the Makefile wouldn't know which .java files would be relevant to the testcase. For this to work the testcase must go into a Java package.
|
||||
|
||||
Any testcases which have _runme.java appended after the testcase name will be detected and run.
|
||||
|
||||
|
|
|
|||
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import cpp11_constexpr.*;
|
||||
|
||||
public class cpp11_constexpr_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_constexpr");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(int received, int expected) {
|
||||
if (expected != received)
|
||||
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
check(cpp11_constexpr.getAAA(), 10);
|
||||
check(cpp11_constexpr.getBBB(), 20);
|
||||
check(cpp11_constexpr.CCC(), 30);
|
||||
check(cpp11_constexpr.DDD(), 40);
|
||||
|
||||
ConstExpressions ce = new ConstExpressions();
|
||||
check(ce.JJJ, 100);
|
||||
check(ce.KKK, 200);
|
||||
check(ce.LLL, 300);
|
||||
check(ce.MMM(), 400);
|
||||
check(ce.NNN(), 500);
|
||||
}
|
||||
}
|
||||
28
Examples/test-suite/java/cpp11_lambda_functions_runme.java
Normal file
28
Examples/test-suite/java/cpp11_lambda_functions_runme.java
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import cpp11_lambda_functions.*;
|
||||
|
||||
public class cpp11_lambda_functions_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_lambda_functions");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(int received, int expected) {
|
||||
if (expected != received)
|
||||
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
check(cpp11_lambda_functions.runLambda1(), 11);
|
||||
check(cpp11_lambda_functions.runLambda2(), 11);
|
||||
check(cpp11_lambda_functions.runLambda3(), 11);
|
||||
check(cpp11_lambda_functions.runLambda4(), 11);
|
||||
check(cpp11_lambda_functions.runLambda5(), 1);
|
||||
check(cpp11_lambda_functions.runLambda5(), 2);
|
||||
}
|
||||
}
|
||||
24
Examples/test-suite/java/cpp11_result_of_runme.java
Normal file
24
Examples/test-suite/java/cpp11_result_of_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import cpp11_result_of.*;
|
||||
|
||||
public class cpp11_result_of_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_result_of");
|
||||
} 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[])
|
||||
{
|
||||
double result = cpp11_result_of.test_result(cpp11_result_ofConstants.SQUARE, 3.0);
|
||||
if (result != 9.0)
|
||||
throw new RuntimeException("test_result(square, 3.0) is not 9.0. Got: " + Double.toString(result));
|
||||
|
||||
result = cpp11_result_of.test_result_alternative1(cpp11_result_ofConstants.SQUARE, 3.0);
|
||||
if (result != 9.0)
|
||||
throw new RuntimeException("test_result_alternative1(square, 3.0) is not 9.0. Got: " + Double.toString(result));
|
||||
}
|
||||
}
|
||||
51
Examples/test-suite/java/cpp11_thread_local_runme.java
Normal file
51
Examples/test-suite/java/cpp11_thread_local_runme.java
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
import cpp11_thread_local.*;
|
||||
|
||||
public class cpp11_thread_local_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_thread_local");
|
||||
} 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 (ThreadLocals.getStval() != 11)
|
||||
throw new RuntimeException();
|
||||
if (ThreadLocals.getTsval() != 22)
|
||||
throw new RuntimeException();
|
||||
if (ThreadLocals.tscval99 != 99)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setEtval(-11);
|
||||
if (cpp11_thread_local.getEtval() != -11)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setStval(-22);
|
||||
if (cpp11_thread_local.getStval() != -22)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setTsval(-33);
|
||||
if (cpp11_thread_local.getTsval() != -33)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setEtval(-44);
|
||||
if (cpp11_thread_local.getEtval() != -44)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setTeval(-55);
|
||||
if (cpp11_thread_local.getTeval() != -55)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setEctval(-55);
|
||||
if (cpp11_thread_local.getEctval() != -55)
|
||||
throw new RuntimeException();
|
||||
|
||||
cpp11_thread_local.setEcpptval(-66);
|
||||
if (cpp11_thread_local.getEcpptval() != -66)
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
22
Examples/test-suite/java/derived_nested_runme.java
Normal file
22
Examples/test-suite/java/derived_nested_runme.java
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
import derived_nested.*;
|
||||
|
||||
public class derived_nested_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("derived_nested");
|
||||
} 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[]) {
|
||||
BB outer = new BB();
|
||||
BB.DD d = new BB.DD();
|
||||
BB.EE e = new BB.EE();
|
||||
outer.getFf_instance().setZ(outer.getFf_instance().getX());
|
||||
outer.useEE(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,8 +22,7 @@ public class dynamic_cast_runme {
|
|||
// Note it is possible to downcast y with a Java cast.
|
||||
String a = dynamic_cast.do_test((Bar)y);
|
||||
if (!a.equals("Bar::test")) {
|
||||
System.err.println("Failed!");
|
||||
System.exit(1);
|
||||
throw new RuntimeException("Failed!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ public class ignore_parameter_runme {
|
|||
{
|
||||
// Compilation will ensure the number of arguments and type are correct.
|
||||
// Then check the return value is the same as the value given to the ignored parameter.
|
||||
if (!ignore_parameter.jaguar(200, 0.0).equals("hello")) { System.err.println("Runtime Error in jaguar()");}
|
||||
if (ignore_parameter.lotus("fast", 0.0) != 101) { System.err.println("Runtime Error in lotus()");}
|
||||
if (ignore_parameter.tvr("fast", 200) != 8.8) { System.err.println("Runtime Error in tvr()");}
|
||||
if (ignore_parameter.ferrari() != 101) { System.err.println("Runtime Error in ferrari()");}
|
||||
if (!ignore_parameter.jaguar(200, 0.0).equals("hello")) { throw new RuntimeException("Runtime Error in jaguar()");}
|
||||
if (ignore_parameter.lotus("fast", 0.0) != 101) { throw new RuntimeException("Runtime Error in lotus()");}
|
||||
if (ignore_parameter.tvr("fast", 200) != 8.8) { throw new RuntimeException("Runtime Error in tvr()");}
|
||||
if (ignore_parameter.ferrari() != 101) { throw new RuntimeException("Runtime Error in ferrari()");}
|
||||
|
||||
SportsCars sc = new SportsCars();
|
||||
if (!sc.daimler(200, 0.0).equals("hello")) { System.err.println("Runtime Error in daimler()");}
|
||||
if (sc.astonmartin("fast", 0.0) != 101) { System.err.println("Runtime Error in astonmartin()");}
|
||||
if (sc.bugatti("fast", 200) != 8.8) { System.err.println("Runtime Error in bugatti()");}
|
||||
if (sc.lamborghini() != 101) { System.err.println("Runtime Error in lamborghini()");}
|
||||
if (!sc.daimler(200, 0.0).equals("hello")) { throw new RuntimeException("Runtime Error in daimler()");}
|
||||
if (sc.astonmartin("fast", 0.0) != 101) { throw new RuntimeException("Runtime Error in astonmartin()");}
|
||||
if (sc.bugatti("fast", 200) != 8.8) { throw new RuntimeException("Runtime Error in bugatti()");}
|
||||
if (sc.lamborghini() != 101) { throw new RuntimeException("Runtime Error in lamborghini()");}
|
||||
|
||||
// Check constructors are also generated correctly
|
||||
MiniCooper mc = new MiniCooper(200, 0.0);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,150 @@
|
|||
import java_director_exception_feature_nspacePackage.*;
|
||||
import java_director_exception_feature_nspacePackage.MyNS.*;
|
||||
|
||||
class java_director_exception_feature_nspace_Consts {
|
||||
public static final String PINGEXCP1 = "Ping MyJavaException1"; // should get translated through an int on ping
|
||||
public static final String PINGEXCP2 = "Ping MyJavaException2";
|
||||
|
||||
public static final String PONGEXCP1 = "Pong MyJavaException1";
|
||||
public static final String PONGEXCP2 = "Pong MyJavaException2";
|
||||
public static final String PONGUNEXPECTED = "Pong MyJavaUnexpected";
|
||||
public static final String TRANSLATED_NPE = "Pong Translated NPE";
|
||||
|
||||
public static final String GENERICPONGEXCP1 = "GenericPong Wrapped MyJavaException1";
|
||||
public static final String GENERICPONGEXCP2 = "GenericPong New Checked Exception";
|
||||
public static final String GENERICPONGEXCP3 = "GenericPong New Unchecked Exception";
|
||||
public static final String GENERICPONGEXCP4 = "GenericPong New Exception Without String ctor";
|
||||
}
|
||||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
class java_director_exception_feature_nspace_NewCheckedException extends Exception {
|
||||
public java_director_exception_feature_nspace_NewCheckedException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
class java_director_exception_feature_nspace_NewUncheckedException extends RuntimeException {
|
||||
public java_director_exception_feature_nspace_NewUncheckedException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
||||
// an exception not constructible from a string,
|
||||
// to test DirectorException fallback reconstruction
|
||||
class java_director_exception_feature_nspace_UnconstructibleException extends Exception {
|
||||
private int extrastate;
|
||||
public java_director_exception_feature_nspace_UnconstructibleException(int a, String s) {
|
||||
super(s);
|
||||
extrastate = a;
|
||||
}
|
||||
}
|
||||
|
||||
class java_director_exception_feature_nspace_MyFooDirectorImpl extends Foo {
|
||||
|
||||
public java_director_exception_feature_nspace_MyFooDirectorImpl() { };
|
||||
|
||||
@Override
|
||||
public String ping(int excp) throws MyJavaException1, MyJavaException2 {
|
||||
if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.PINGEXCP1);
|
||||
if (excp == 2) throw new MyJavaException2(java_director_exception_feature_nspace_Consts.PINGEXCP2);
|
||||
return "Ping director returned";
|
||||
}
|
||||
@Override
|
||||
public String pong(int excp) throws MyJavaException1, MyJavaException2, MyJavaUnexpected {
|
||||
if (excp == 1) throw new MyJavaException1(java_director_exception_feature_nspace_Consts.PONGEXCP1);
|
||||
if (excp == 2) throw new MyJavaException2(java_director_exception_feature_nspace_Consts.PONGEXCP2);
|
||||
if (excp == 3) throw new MyJavaUnexpected(java_director_exception_feature_nspace_Consts.PONGUNEXPECTED);
|
||||
if (excp == 4) throw new java.lang.NullPointerException(java_director_exception_feature_nspace_Consts.TRANSLATED_NPE); // should be translated to ::Unexpected
|
||||
return "Pong director returned";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String genericpong(int excp) throws MyJavaException1, java_director_exception_feature_nspace_NewCheckedException, java_director_exception_feature_nspace_UnconstructibleException {
|
||||
if (excp == 1)
|
||||
throw new MyJavaException1(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1);
|
||||
if (excp == 2)
|
||||
throw new java_director_exception_feature_nspace_NewCheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2);
|
||||
if (excp == 3)
|
||||
throw new java_director_exception_feature_nspace_NewUncheckedException(java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3);
|
||||
if (excp == 4)
|
||||
throw new java_director_exception_feature_nspace_UnconstructibleException(1, java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4);
|
||||
return "GenericPong director returned";
|
||||
}
|
||||
}
|
||||
|
||||
public class java_director_exception_feature_nspace_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("java_director_exception_feature_nspace");
|
||||
} 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 fail(String msg) {
|
||||
System.err.println(msg); System.exit(1);
|
||||
}
|
||||
public static void failif(boolean cond, String msg) {
|
||||
if (cond) fail(msg);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
Bar b = new Bar(new java_director_exception_feature_nspace_MyFooDirectorImpl());
|
||||
try {
|
||||
|
||||
try { b.ping(0); } catch (Exception e)
|
||||
{ fail("Exception should not have been thrown: " + e + " from ping(0)"); }
|
||||
try { b.ping(1); fail("No exception thrown in ping(1)"); } catch (MyJavaException1 e)
|
||||
// Should say "Threw some integer", see java_director_exception_feature.i Foo::ping throws a "1"
|
||||
{ failif( ! "Threw some integer".equals(e.getMessage()), "Ping exception not translated through int: '" + e.getMessage() + "'"); }
|
||||
try { b.ping(2); fail("No exception thrown in ping(2)"); } catch (MyJavaException2 e)
|
||||
{ failif( ! java_director_exception_feature_nspace_Consts.PINGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
|
||||
try { b.pong(0); } catch (Exception e)
|
||||
{ fail("Exception should not have been thrown: " + e + " from pong(0)"); }
|
||||
try { b.pong(1); fail("No exception thrown in pong(1)"); } catch (MyJavaException1 e)
|
||||
{ failif( ! java_director_exception_feature_nspace_Consts.PONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(2); fail("No exception thrown in pong(2)");} catch (MyJavaException2 e)
|
||||
{ failif( ! java_director_exception_feature_nspace_Consts.PONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(3); fail("No exception thrown in pong(3)");} catch (MyJavaUnexpected e)
|
||||
{ failif( ! java_director_exception_feature_nspace_Consts.PONGUNEXPECTED.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(4); fail("No exception thrown in pong(4)"); } catch (MyJavaUnexpected e)
|
||||
{ failif( ! java_director_exception_feature_nspace_Consts.TRANSLATED_NPE.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
|
||||
|
||||
try { b.genericpong(0); }
|
||||
catch (Exception e) {
|
||||
fail("Exception should not have been thrown: " + e + " from genericpong(0)");
|
||||
}
|
||||
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
|
||||
catch (MyJavaException1 e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
|
||||
catch (java_director_exception_feature_nspace_NewCheckedException e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
|
||||
catch (java_director_exception_feature_nspace_NewUncheckedException e) {
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
|
||||
catch (RuntimeException e) {
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
|
||||
failif( ! java_director_exception_feature_nspace_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("Unexpected exception thrown or exception not mapped properly");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
|
||||
import java_director_exception_feature.*;
|
||||
|
||||
class java_director_exception_feature_Consts {
|
||||
public static final String PINGEXCP1 = "Ping MyJavaException1"; // should get translated through an int on ping
|
||||
public static final String PINGEXCP2 = "Ping MyJavaException2";
|
||||
|
||||
public static final String PONGEXCP1 = "Pong MyJavaException1";
|
||||
public static final String PONGEXCP2 = "Pong MyJavaException2";
|
||||
public static final String PONGUNEXPECTED = "Pong MyJavaUnexpected";
|
||||
public static final String TRANSLATED_NPE = "Pong Translated NPE";
|
||||
|
||||
public static final String GENERICPONGEXCP1 = "GenericPong Wrapped MyJavaException1";
|
||||
public static final String GENERICPONGEXCP2 = "GenericPong New Checked Exception";
|
||||
public static final String GENERICPONGEXCP3 = "GenericPong New Unchecked Exception";
|
||||
public static final String GENERICPONGEXCP4 = "GenericPong New Exception Without String ctor";
|
||||
|
||||
}
|
||||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
class NewCheckedException extends Exception {
|
||||
public NewCheckedException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
||||
// an exception not mentioned or wrapped by the swig interface,
|
||||
// to reconstruct using generic DirectorException handling
|
||||
class NewUncheckedException extends RuntimeException {
|
||||
public NewUncheckedException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
|
||||
// an exception not constructable from a string,
|
||||
// to test DirectorException fallback reconstruction
|
||||
class UnconstructableException extends Exception {
|
||||
private int extrastate;
|
||||
public UnconstructableException(int a, String s) {
|
||||
super(s);
|
||||
extrastate = a;
|
||||
}
|
||||
}
|
||||
|
||||
class java_director_exception_feature_MyFooDirectorImpl extends Foo {
|
||||
|
||||
public java_director_exception_feature_MyFooDirectorImpl() { };
|
||||
|
||||
@Override
|
||||
public String ping(int excp) throws MyJavaException1, MyJavaException2 {
|
||||
if (excp == 1) throw new MyJavaException1(java_director_exception_feature_Consts.PINGEXCP1);
|
||||
if (excp == 2) throw new MyJavaException2(java_director_exception_feature_Consts.PINGEXCP2);
|
||||
return "Ping director returned";
|
||||
}
|
||||
@Override
|
||||
public String pong(int excp) throws MyJavaException1, MyJavaException2, MyJavaUnexpected {
|
||||
if (excp == 1) throw new MyJavaException1(java_director_exception_feature_Consts.PONGEXCP1);
|
||||
if (excp == 2) throw new MyJavaException2(java_director_exception_feature_Consts.PONGEXCP2);
|
||||
if (excp == 3) throw new MyJavaUnexpected(java_director_exception_feature_Consts.PONGUNEXPECTED);
|
||||
if (excp == 4) throw new java.lang.NullPointerException(java_director_exception_feature_Consts.TRANSLATED_NPE); // should be translated to ::Unexpected
|
||||
return "Pong director returned";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String genericpong(int excp) throws MyJavaException1, NewCheckedException, UnconstructableException {
|
||||
if (excp == 1)
|
||||
throw new MyJavaException1(java_director_exception_feature_Consts.GENERICPONGEXCP1);
|
||||
if (excp == 2)
|
||||
throw new NewCheckedException(java_director_exception_feature_Consts.GENERICPONGEXCP2);
|
||||
if (excp == 3)
|
||||
throw new NewUncheckedException(java_director_exception_feature_Consts.GENERICPONGEXCP3);
|
||||
if (excp == 4)
|
||||
throw new UnconstructableException(1, java_director_exception_feature_Consts.GENERICPONGEXCP4);
|
||||
return "GenericPong director returned";
|
||||
}
|
||||
}
|
||||
|
||||
public class java_director_exception_feature_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("java_director_exception_feature");
|
||||
} 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 fail(String msg) {
|
||||
System.err.println(msg); System.exit(1);
|
||||
}
|
||||
public static void failif(boolean cond, String msg) {
|
||||
if (cond) fail(msg);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String argv[]) {
|
||||
|
||||
Bar b = new Bar(new java_director_exception_feature_MyFooDirectorImpl());
|
||||
try {
|
||||
|
||||
try { b.ping(0); } catch (Exception e)
|
||||
{ fail("Exception should not have been thrown: " + e + " from ping(0)"); }
|
||||
try { b.ping(1); fail("No exception thrown in ping(1)"); } catch (MyJavaException1 e)
|
||||
// Should say "Threw some integer", see java_director_exception_feature.i Foo::ping throws a "1"
|
||||
{ failif( ! "Threw some integer".equals(e.getMessage()), "Ping exception not translated through int: '" + e.getMessage() + "'"); }
|
||||
try { b.ping(2); fail("No exception thrown in ping(2)"); } catch (MyJavaException2 e)
|
||||
{ failif( ! java_director_exception_feature_Consts.PINGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
|
||||
try { b.pong(0); } catch (Exception e)
|
||||
{ fail("Exception should not have been thrown: " + e + " from pong(0)"); }
|
||||
try { b.pong(1); fail("No exception thrown in pong(1)"); } catch (MyJavaException1 e)
|
||||
{ failif( ! java_director_exception_feature_Consts.PONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(2); fail("No exception thrown in pong(2)");} catch (MyJavaException2 e)
|
||||
{ failif( ! java_director_exception_feature_Consts.PONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(3); fail("No exception thrown in pong(3)");} catch (MyJavaUnexpected e)
|
||||
{ failif( ! java_director_exception_feature_Consts.PONGUNEXPECTED.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
try { b.pong(4); fail("No exception thrown in pong(4)"); } catch (MyJavaUnexpected e)
|
||||
{ failif( ! java_director_exception_feature_Consts.TRANSLATED_NPE.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'"); }
|
||||
|
||||
|
||||
try { b.genericpong(0); }
|
||||
catch (Exception e) {
|
||||
fail("Exception should not have been thrown: " + e + " from genericpong(0)");
|
||||
}
|
||||
try { b.genericpong(1); fail("No exception thrown in genericpong(1)"); }
|
||||
catch (MyJavaException1 e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP1.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(2); fail("No exception thrown in genericpong(2)");}
|
||||
catch (NewCheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP2.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(3); fail("No exception thrown in genericpong(3)");}
|
||||
catch (NewUncheckedException e) {
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP3.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
try { b.genericpong(4); fail("No exception thrown in genericpong(4)");}
|
||||
catch (RuntimeException e) {
|
||||
failif ( e.getClass() != RuntimeException.class, "Exception " + e + " is not exactly RumtimeException");
|
||||
failif( ! java_director_exception_feature_Consts.GENERICPONGEXCP4.equals(e.getMessage()), "Expected exception has unexpected message: '" + e.getMessage() + "'");
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("Unexpected exception thrown or exception not mapped properly");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,16 @@ public class java_director_runme {
|
|||
}
|
||||
}
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
QuuxContainer qc = createContainer();
|
||||
|
||||
|
|
@ -31,24 +41,21 @@ public class java_director_runme {
|
|||
qc = null;
|
||||
/* Watch qc get reaped, which causes the C++ object to delete
|
||||
objects from the internal vector */
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
|
||||
// Give the finalizers a chance to run
|
||||
try {
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Quux.instances() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Quux.instances();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
/* Watch the Quux objects formerly in the QuuxContainer object
|
||||
get reaped */
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
|
||||
instances = Quux.instances();
|
||||
if (instances != 0)
|
||||
throw new RuntimeException("Quux instances should be 0, actually " + instances);
|
||||
|
||||
/* Test Quux1's director disconnect method rename */
|
||||
Quux1 quux1 = new Quux1("quux1");
|
||||
if (quux1.disconnectMethodCalled)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ public class java_jnitypes_runme {
|
|||
}
|
||||
|
||||
public static void testFailed(String str) {
|
||||
System.err.println(str + " test failed");
|
||||
System.exit(1);
|
||||
throw new RuntimeException(str + " test failed");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,16 @@ public class li_boost_intrusive_ptr_runme {
|
|||
// Debugging flag
|
||||
public final static boolean debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -23,7 +33,7 @@ public class li_boost_intrusive_ptr_runme {
|
|||
// Change loop count to run for a long time to monitor memory
|
||||
final int loopCount = 5000; //5000;
|
||||
for (int i=0; i<loopCount; i++) {
|
||||
new li_boost_intrusive_ptr_runme().runtest();
|
||||
new li_boost_intrusive_ptr_runme().runtest(i);
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
|
|
@ -39,12 +49,7 @@ public class li_boost_intrusive_ptr_runme {
|
|||
|
||||
int countdown = 50;
|
||||
while (true) {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(100);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
|
||||
|
|
@ -52,7 +57,7 @@ public class li_boost_intrusive_ptr_runme {
|
|||
KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
|
||||
// Expect 1 Klass instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
}
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
||||
if (KlassWithoutRefCount.getTotal_count() != 0)
|
||||
|
|
@ -73,7 +78,9 @@ public class li_boost_intrusive_ptr_runme {
|
|||
System.out.println("Finished");
|
||||
}
|
||||
|
||||
private void runtest() {
|
||||
private int loopCount = 0;
|
||||
private void runtest(int loopCount) {
|
||||
this.loopCount = loopCount;
|
||||
// simple shared_ptr usage - created in C++
|
||||
{
|
||||
Klass k = new Klass("me oh my");
|
||||
|
|
@ -666,36 +673,36 @@ private void toIgnore() {
|
|||
}
|
||||
private void verifyValue(String expected, String got) {
|
||||
if (!expected.equals(got))
|
||||
throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyCount(int expected, Klass k) {
|
||||
int got = li_boost_intrusive_ptr.use_count(k);
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyCount(int expected, KlassDerived kd) {
|
||||
int got = li_boost_intrusive_ptr.use_count(kd);
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyCount(int expected, KlassDerivedDerived kdd) {
|
||||
int got = li_boost_intrusive_ptr.use_count(kdd);
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyIntrusiveCount(int expected, Klass k) {
|
||||
int got = k.use_count();
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyIntrusiveCount(int expected, KlassDerived kd) {
|
||||
int got = kd.use_count();
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
|
||||
int got = kdd.use_count();
|
||||
if (expected != got)
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
|
||||
throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got + " loopCount: " + loopCount);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
import li_boost_shared_ptr_attribute.*;
|
||||
|
||||
public class li_boost_shared_ptr_attribute_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_boost_shared_ptr_attribute");
|
||||
} 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 check(GetSetMe g, int expected) {
|
||||
int got = g.getN();
|
||||
if (got != expected)
|
||||
throw new RuntimeException("GetSetMe value is " + got + " but should be " + expected);
|
||||
}
|
||||
|
||||
public static void check(GetMe g, int expected) {
|
||||
int got = g.getN();
|
||||
if (got != expected)
|
||||
throw new RuntimeException("GetMe value is " + got + " but should be " + expected);
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
GetterSetter gs = new GetterSetter(5);
|
||||
check(gs.getMyval(), 25);
|
||||
check(gs.getAddedAttrib(), 25);
|
||||
gs.setAddedAttrib(new GetSetMe(6));
|
||||
check(gs.getMyval(), 6);
|
||||
check(gs.getAddedAttrib(), 6);
|
||||
|
||||
GetterOnly g = new GetterOnly(4);
|
||||
check(g.getMyval(), 16);
|
||||
check(g.getAddedAttrib(), 16);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,16 @@ public class li_boost_shared_ptr_runme {
|
|||
// Debugging flag
|
||||
public final static boolean debug = false;
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
if (debug)
|
||||
|
|
@ -37,21 +47,20 @@ public class li_boost_shared_ptr_runme {
|
|||
if (debug)
|
||||
System.out.println("Nearly finished");
|
||||
|
||||
int countdown = 100;
|
||||
while (true) {
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount) // Expect the one global variable (GlobalValue)
|
||||
break;
|
||||
}
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == 1) // Expect 1 instance - the one global variable (GlobalValue)
|
||||
break;
|
||||
};
|
||||
if (Klass.getTotal_count() != 1)
|
||||
throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count();
|
||||
if (wrapper_count != li_boost_shared_ptr.getNOT_COUNTING())
|
||||
|
|
|
|||
24
Examples/test-suite/java/li_cdata_runme.java
Normal file
24
Examples/test-suite/java/li_cdata_runme.java
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import li_cdata.*;
|
||||
|
||||
public class li_cdata_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_cdata");
|
||||
} 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[]) throws Throwable
|
||||
{
|
||||
byte[] s = "ABC abc".getBytes();
|
||||
SWIGTYPE_p_void m = li_cdata.malloc(256);
|
||||
li_cdata.memmove(m, s);
|
||||
byte[] ss = li_cdata.cdata(m, 7);
|
||||
String ss_string = new String(ss);
|
||||
if (!ss_string.equals("ABC abc"))
|
||||
throw new RuntimeException("failed got: " + ss_string);
|
||||
}
|
||||
}
|
||||
68
Examples/test-suite/java/li_std_auto_ptr_runme.java
Normal file
68
Examples/test-suite/java/li_std_auto_ptr_runme.java
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
import li_std_auto_ptr.*;
|
||||
|
||||
public class li_std_auto_ptr_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("li_std_auto_ptr");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
private static void WaitForGC()
|
||||
{
|
||||
System.gc();
|
||||
System.runFinalization();
|
||||
try {
|
||||
java.lang.Thread.sleep(10);
|
||||
} catch (java.lang.InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) throws Throwable
|
||||
{
|
||||
Klass k1 = li_std_auto_ptr.makeKlassAutoPtr("first");
|
||||
if (!k1.getLabel().equals("first"))
|
||||
throw new RuntimeException("wrong object label");
|
||||
|
||||
Klass k2 = li_std_auto_ptr.makeKlassAutoPtr("second");
|
||||
if (Klass.getTotal_count() != 2)
|
||||
throw new RuntimeException("number of objects should be 2");
|
||||
|
||||
k1 = null;
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 1;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
}
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
|
||||
if (!k2.getLabel().equals("second"))
|
||||
throw new RuntimeException("wrong object label");
|
||||
|
||||
k2 = null;
|
||||
{
|
||||
int countdown = 500;
|
||||
int expectedCount = 0;
|
||||
while (true) {
|
||||
WaitForGC();
|
||||
if (--countdown == 0)
|
||||
break;
|
||||
if (Klass.getTotal_count() == expectedCount)
|
||||
break;
|
||||
};
|
||||
int actualCount = Klass.getTotal_count();
|
||||
if (actualCount != expectedCount)
|
||||
throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -66,8 +66,7 @@ public class long_long_runme {
|
|||
long_long.setLl(ll);
|
||||
long ll_check = long_long.getLl();
|
||||
if (ll != ll_check) {
|
||||
System.err.println("Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check);
|
||||
System.exit(1);
|
||||
throw new RuntimeException("Runtime test using long long failed. ll=" + ll + " ll_check=" + ll_check);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +74,7 @@ public class long_long_runme {
|
|||
long_long.setUll(ull);
|
||||
BigInteger ull_check = long_long.getUll();
|
||||
if (ull.compareTo(ull_check) != 0) {
|
||||
System.err.println("Runtime test using unsigned long long failed. ull=" + ull.toString() + " ull_check=" + ull_check.toString());
|
||||
System.exit(1);
|
||||
throw new RuntimeException("Runtime test using unsigned long long failed. ull=" + ull.toString() + " ull_check=" + ull_check.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
Examples/test-suite/java/naturalvar_more_runme.java
Normal file
23
Examples/test-suite/java/naturalvar_more_runme.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
import naturalvar_more.*;
|
||||
|
||||
public class naturalvar_more_runme {
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("naturalvar_more");
|
||||
} 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[])
|
||||
{
|
||||
S s = new S();
|
||||
if (!s.getConst_string_member().equals("initial string value"))
|
||||
throw new RuntimeException("Test 1 fail");
|
||||
s.setString_member("some member value");
|
||||
if (!s.getString_member().equals("some member value"))
|
||||
throw new RuntimeException("Test 2 fail");
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue