diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2015-01-14 13:45:55 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2015-01-14 13:45:55 +0000 |
commit | efa96eb76d4f1a6b14633ab653699352936fe3d1 (patch) | |
tree | 0b13e154013ab12d06cf0eadd4740d9fd9b79731 /Examples/test-suite/java | |
parent | 6d86fb173915867bd70d6780a174bce3c5b3c1df (diff) | |
parent | 4fed2e6690b1486952b0543b6bde28573eb0d132 (diff) | |
download | swig-coverity-scan.tar.gz |
Merge branch 'master' into coverity-scancoverity-scan
* master: (478 commits)
Use -rrbconfig rather than -rmkmf to load rbconfig
Add suggestion to check block delimiter
Add explanatory comment to pp_unknowndirective2.i
Fix PHP crash in director_finalizer
Add 3.0.4 release information
Fix typo
Note 1.8 as the oldest supported version
Fix PHP backend for default_args testcase
Update html
Python 3 default args fix
Revert introduction of python:defaultargs feature
Ruby: Replace Config::CONFIG with RbConfig::CONFIG in configure.ac
Add regression test for #217
[PHP] Fix segfault in director upcall check
Fix linux gcc warnings and strtol corrections
Tests for Python default arguments and %pythondefaultargs.
Python default arg improvements
[lua/luarun] change return type from int to void on functions not returning anything
Add note about delimiting blocks of Python code
Fix python default_args testcase for Python 3
Fix Python default argument handing broken since swig-3.0.3
Python default argument test cases from issue #294
Wording change for missing semicolon error
Handle "constexpr explicit" and "constexpr static"
Allow C++11 "explicit constexpr"
Improve errors for missing ; and unexpected )
Fix typo in old entry
Add test coverage for unterminated %{ ... %} block
When reporting an error for a construct which hasn't been terminated when the end of the file is reached, report it at the start line rather than "EOF" as then tools like editors and IDEs will take you to a generally more useful place for fixing the problem.
Improve error message for extraneous '%}'.
Add .gitignore for Examples/test-suite/errors/
Fix testcase name in expected output
Improve error message when an unknown SWIG directive is used
Update link to point to 3.0 docs
Fix links to the online 1.3 docs to instead be relative
Drop deprecated warnings for ancient options
Fix tab to space in HTML preformatted block
Provide -cppext as a general command line option
Split -help output into 4 chunks instead of 3
More on Go examples [skip ci]
Properly quote parameters in preinst-swig wrapper.
Fix typo
Bump version to 3.0.4
HTML tweaks
Add 3.0.3 release information
Minor tweaks to the changes file
%constant and structs support for Lua
Fix D examples when run 'in-source'
Fix D examples clean
Revert "Fix D examples clean"
Fix javascript clean
Let Octave 3.8 fail in Travis
Fix D examples clean
Fix javascript clean
Tidy up Javascript build system
Don't delete checked in files with 'make distclean'
Reduce scope of template_default_class_parms testcase
Fix abort using template default parameters
Test suite warning fixes
[Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code under clang
Issue #282 perl5 archlib vs archlibexp
[Go] Changed link 'https://github.com/golang/go/tree/master/misc/swig' to 'https://golang.org/misc/swig' in the Go documentation.
[Go] Updated Go documentation (examples, runtime.SetFinalizer, object ownership).
Added auto-generated 'Examples/d/example.mk' to '.gitignore'.
Warning suppressions in tests
nested_scope test fixes for clang
Fix use of preprocessor null directive
Add testcase for nested inner class deriving from a templated base class and defined outside of the outer class.
Add in missing constant_directive.i test
Improve Python builtin and %constant structs
fixed python global object constants
Partial support for %constant and structs
Ignore E402 (import not on top of file) PEP8 error.
Add PEP8_FLAGS variable to the test suite Python makefile.
Fix templated constructors regression
Correctly detect Go1 during configure
Fix regression in introduced in merge of C++11 strongly typed enums support - Guile constants bad casts generated - Go non-public enum value wrappers assert failure
Document new C++11 strongly typed enumerations support.
Add more docs about _global_ prefix in typemap temporary variables
Add clarification on _global_ prefix.
Improve Javascript Webkit detection
Add c++11 strongly typed enums runtime test for Javascript
Add c++11 strongly typed enums runtime test for Octave
Add c++11 strongly typed enum support for Guile
Add c++11 strongly typed enum support for Go
Add c++11 strongly typed enum support for D
Add c++11 strongly typed enum support for Lua
Fix line endings in lua example
Add c++11 strongly typed enums runtime test for Tcl
Add c++11 strongly typed enum support for PHP
Add c++11 strongly typed enums runtime test for Ruby
Add c++11 strongly typed enums runtime test for Perl
Enhance C++11 strongly typed enums testcase
C++11 strongly typed enums runtime test for python
fix for nested template defined out of class (issue #265)
C++11 strongly typed enum support
Add Java runtime testcases for C++11 strongly typed enums
add director_nested_class to list of broken tests
Add C# support for wrapping C++11 strongly typed enums
Enhance strongly typed enums testcase
...
Conflicts:
.travis.yml
Diffstat (limited to 'Examples/test-suite/java')
18 files changed, 601 insertions, 26 deletions
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 059325c13..310f1a773 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -7,6 +7,7 @@ JAVA = @JAVA@ JAVAC = @JAVAC@ JAVAFLAGS = -Xcheck:jni SCRIPTSUFFIX = _runme.java + srcdir = @srcdir@ top_srcdir = ../@top_srcdir@ top_builddir = ../@top_builddir@ @@ -39,9 +40,13 @@ CPP_TEST_CASES = \ java_typemaps_typewrapper # li_boost_intrusive_ptr +CPP11_TEST_CASES = \ + cpp11_strongly_typed_enumerations_simple \ + include $(srcdir)/../common.mk # Overridden variables here +SRCDIR = ../$(srcdir)/ JAVA_PACKAGE = $* JAVA_PACKAGEOPT = -package $(JAVA_PACKAGE) SWIGOPT += $(JAVA_PACKAGEOPT) @@ -55,7 +60,7 @@ 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) @@ -65,14 +70,14 @@ 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 \ + if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ echo "$(ACTION)ing $(LANGUAGE) testcase $* (with run test)" ; \ else \ echo "$(ACTION)ing $(LANGUAGE) testcase $*" ; \ @@ -86,8 +91,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 diff --git a/Examples/test-suite/java/constant_directive_runme.java b/Examples/test-suite/java/constant_directive_runme.java new file mode 100644 index 000000000..b5135a499 --- /dev/null +++ b/Examples/test-suite/java/constant_directive_runme.java @@ -0,0 +1,22 @@ +import constant_directive.*; + +public class constant_directive_runme { + + static { + try { + System.loadLibrary("constant_directive"); + } 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 (constant_directive.TYPE1_CONSTANT1.getVal() != 1) + throw new RuntimeException("fail"); + if (constant_directive.TYPE1_CONSTANT2.getVal() != 2) + throw new RuntimeException("fail"); + if (constant_directive.TYPE1_CONSTANT3.getVal() != 3) + throw new RuntimeException("fail"); + } +} diff --git a/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java new file mode 100644 index 000000000..3e0b3f651 --- /dev/null +++ b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_runme.java @@ -0,0 +1,176 @@ +import cpp11_strongly_typed_enumerations.*; + +public class cpp11_strongly_typed_enumerations_runme { + + static { + try { + System.loadLibrary("cpp11_strongly_typed_enumerations"); + } 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 int enumCheck(int actual, int expected) { + if (actual != expected) + throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual); + return expected + 1; + } + + public static void main(String argv[]) { + int val = 0; + val = enumCheck(Enum1.Val1.swigValue(), val); + val = enumCheck(Enum1.Val2.swigValue(), val); + val = enumCheck(Enum1.Val3.swigValue(), 13); + val = enumCheck(Enum1.Val4.swigValue(), val); + val = enumCheck(Enum1.Val5a.swigValue(), 13); + val = enumCheck(Enum1.Val6a.swigValue(), val); + + val = 0; + val = enumCheck(Enum2.Val1.swigValue(), val); + val = enumCheck(Enum2.Val2.swigValue(), val); + val = enumCheck(Enum2.Val3.swigValue(), 23); + val = enumCheck(Enum2.Val4.swigValue(), val); + val = enumCheck(Enum2.Val5b.swigValue(), 23); + val = enumCheck(Enum2.Val6b.swigValue(), val); + + val = 0; + val = enumCheck(Enum4.Val1.swigValue(), val); + val = enumCheck(Enum4.Val2.swigValue(), val); + val = enumCheck(Enum4.Val3.swigValue(), 43); + val = enumCheck(Enum4.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Enum5.Val1.swigValue(), val); + val = enumCheck(Enum5.Val2.swigValue(), val); + val = enumCheck(Enum5.Val3.swigValue(), 53); + val = enumCheck(Enum5.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Enum6.Val1.swigValue(), val); + val = enumCheck(Enum6.Val2.swigValue(), val); + val = enumCheck(Enum6.Val3.swigValue(), 63); + val = enumCheck(Enum6.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Enum7td.Val1.swigValue(), val); + val = enumCheck(Enum7td.Val2.swigValue(), val); + val = enumCheck(Enum7td.Val3.swigValue(), 73); + val = enumCheck(Enum7td.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Enum8.Val1.swigValue(), val); + val = enumCheck(Enum8.Val2.swigValue(), val); + val = enumCheck(Enum8.Val3.swigValue(), 83); + val = enumCheck(Enum8.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Enum10.Val1.swigValue(), val); + val = enumCheck(Enum10.Val2.swigValue(), val); + val = enumCheck(Enum10.Val3.swigValue(), 103); + val = enumCheck(Enum10.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Enum12.Val1.swigValue(), 1121); + val = enumCheck(Class1.Enum12.Val2.swigValue(), 1122); + val = enumCheck(Class1.Enum12.Val3.swigValue(), val); + val = enumCheck(Class1.Enum12.Val4.swigValue(), val); + val = enumCheck(Class1.Enum12.Val5c.swigValue(), 1121); + val = enumCheck(Class1.Enum12.Val6c.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Enum13.Val1.swigValue(), 1131); + val = enumCheck(Class1.Enum13.Val2.swigValue(), 1132); + val = enumCheck(Class1.Enum13.Val3.swigValue(), val); + val = enumCheck(Class1.Enum13.Val4.swigValue(), val); + val = enumCheck(Class1.Enum13.Val5d.swigValue(), 1131); + val = enumCheck(Class1.Enum13.Val6d.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Enum14.Val1.swigValue(), 1141); + val = enumCheck(Class1.Enum14.Val2.swigValue(), 1142); + val = enumCheck(Class1.Enum14.Val3.swigValue(), val); + val = enumCheck(Class1.Enum14.Val4.swigValue(), val); + val = enumCheck(Class1.Enum14.Val5e.swigValue(), 1141); + val = enumCheck(Class1.Enum14.Val6e.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Struct1.Enum12.Val1.swigValue(), 3121); + val = enumCheck(Class1.Struct1.Enum12.Val2.swigValue(), 3122); + val = enumCheck(Class1.Struct1.Enum12.Val3.swigValue(), val); + val = enumCheck(Class1.Struct1.Enum12.Val4.swigValue(), val); + val = enumCheck(Class1.Struct1.Enum12.Val5f.swigValue(), 3121); + val = enumCheck(Class1.Struct1.Enum12.Val6f.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Struct1.Enum13.Val1.swigValue(), 3131); + val = enumCheck(Class1.Struct1.Enum13.Val2.swigValue(), 3132); + val = enumCheck(Class1.Struct1.Enum13.Val3.swigValue(), val); + val = enumCheck(Class1.Struct1.Enum13.Val4.swigValue(), val); + + val = 0; + val = enumCheck(Class1.Struct1.Enum14.Val1.swigValue(), 3141); + val = enumCheck(Class1.Struct1.Enum14.Val2.swigValue(), 3142); + val = enumCheck(Class1.Struct1.Enum14.Val3.swigValue(), val); + val = enumCheck(Class1.Struct1.Enum14.Val4.swigValue(), val); + val = enumCheck(Class1.Struct1.Enum14.Val5g.swigValue(), 3141); + val = enumCheck(Class1.Struct1.Enum14.Val6g.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Enum12.Val1.swigValue(), 2121); + val = enumCheck(Class2.Enum12.Val2.swigValue(), 2122); + val = enumCheck(Class2.Enum12.Val3.swigValue(), val); + val = enumCheck(Class2.Enum12.Val4.swigValue(), val); + val = enumCheck(Class2.Enum12.Val5h.swigValue(), 2121); + val = enumCheck(Class2.Enum12.Val6h.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Enum13.Val1.swigValue(), 2131); + val = enumCheck(Class2.Enum13.Val2.swigValue(), 2132); + val = enumCheck(Class2.Enum13.Val3.swigValue(), val); + val = enumCheck(Class2.Enum13.Val4.swigValue(), val); + val = enumCheck(Class2.Enum13.Val5i.swigValue(), 2131); + val = enumCheck(Class2.Enum13.Val6i.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Enum14.Val1.swigValue(), 2141); + val = enumCheck(Class2.Enum14.Val2.swigValue(), 2142); + val = enumCheck(Class2.Enum14.Val3.swigValue(), val); + val = enumCheck(Class2.Enum14.Val4.swigValue(), val); + val = enumCheck(Class2.Enum14.Val5j.swigValue(), 2141); + val = enumCheck(Class2.Enum14.Val6j.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Struct1.Enum12.Val1.swigValue(), 4121); + val = enumCheck(Class2.Struct1.Enum12.Val2.swigValue(), 4122); + val = enumCheck(Class2.Struct1.Enum12.Val3.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum12.Val4.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum12.Val5k.swigValue(), 4121); + val = enumCheck(Class2.Struct1.Enum12.Val6k.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Struct1.Enum13.Val1.swigValue(), 4131); + val = enumCheck(Class2.Struct1.Enum13.Val2.swigValue(), 4132); + val = enumCheck(Class2.Struct1.Enum13.Val3.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum13.Val4.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum13.Val5l.swigValue(), 4131); + val = enumCheck(Class2.Struct1.Enum13.Val6l.swigValue(), val); + + val = 0; + val = enumCheck(Class2.Struct1.Enum14.Val1.swigValue(), 4141); + val = enumCheck(Class2.Struct1.Enum14.Val2.swigValue(), 4142); + val = enumCheck(Class2.Struct1.Enum14.Val3.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum14.Val4.swigValue(), val); + val = enumCheck(Class2.Struct1.Enum14.Val5m.swigValue(), 4141); + val = enumCheck(Class2.Struct1.Enum14.Val6m.swigValue(), val); + + Class1 class1 = new Class1(); + enumCheck(class1.class1Test1(Enum1.Val5a).swigValue(), 13); + enumCheck(class1.class1Test2(Class1.Enum12.Val5c).swigValue(), 1121); + enumCheck(class1.class1Test3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121); + + enumCheck(cpp11_strongly_typed_enumerations.globalTest1(Enum1.Val5a).swigValue(), 13); + enumCheck(cpp11_strongly_typed_enumerations.globalTest2(Class1.Enum12.Val5c).swigValue(), 1121); + enumCheck(cpp11_strongly_typed_enumerations.globalTest3(Class1.Struct1.Enum12.Val5f).swigValue(), 3121); + } +} diff --git a/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java new file mode 100644 index 000000000..b50e94893 --- /dev/null +++ b/Examples/test-suite/java/cpp11_strongly_typed_enumerations_simple_runme.java @@ -0,0 +1,176 @@ +import cpp11_strongly_typed_enumerations_simple.*; + +public class cpp11_strongly_typed_enumerations_simple_runme { + + static { + try { + System.loadLibrary("cpp11_strongly_typed_enumerations_simple"); + } 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 int enumCheck(int actual, int expected) { + if (actual != expected) + throw new RuntimeException("Enum value mismatch. Expected " + expected + " Actual: " + actual); + return expected + 1; + } + + public static void main(String argv[]) { + int val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val3, 13); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val4, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a, 13); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum1_Val6a, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val3, 23); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val4, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val5b, 23); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum2_Val6b, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val3, 43); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Val4, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val3, 53); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum5_Val4, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val3, 63); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum6_Val4, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val3, 73); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum7td_Val4, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val3, 83); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum8_Val4, val); + + val = 0; + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val1, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val2, val); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val3, 103); + val = enumCheck(cpp11_strongly_typed_enumerations_simple.Enum10_Val4, val); + + val = 0; + val = enumCheck(Class1.Enum12_Val1, 1121); + val = enumCheck(Class1.Enum12_Val2, 1122); + val = enumCheck(Class1.Enum12_Val3, val); + val = enumCheck(Class1.Enum12_Val4, val); + val = enumCheck(Class1.Enum12_Val5c, 1121); + val = enumCheck(Class1.Enum12_Val6c, val); + + val = 0; + val = enumCheck(Class1.Val1, 1131); + val = enumCheck(Class1.Val2, 1132); + val = enumCheck(Class1.Val3, val); + val = enumCheck(Class1.Val4, val); + val = enumCheck(Class1.Val5d, 1131); + val = enumCheck(Class1.Val6d, val); + + val = 0; + val = enumCheck(Class1.Enum14_Val1, 1141); + val = enumCheck(Class1.Enum14_Val2, 1142); + val = enumCheck(Class1.Enum14_Val3, val); + val = enumCheck(Class1.Enum14_Val4, val); + val = enumCheck(Class1.Enum14_Val5e, 1141); + val = enumCheck(Class1.Enum14_Val6e, val); + + val = 0; + val = enumCheck(Class1.Struct1.Enum12_Val1, 3121); + val = enumCheck(Class1.Struct1.Enum12_Val2, 3122); + val = enumCheck(Class1.Struct1.Enum12_Val3, val); + val = enumCheck(Class1.Struct1.Enum12_Val4, val); + val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121); + val = enumCheck(Class1.Struct1.Enum12_Val6f, val); + + val = 0; + val = enumCheck(Class1.Struct1.Val1, 3131); + val = enumCheck(Class1.Struct1.Val2, 3132); + val = enumCheck(Class1.Struct1.Val3, val); + val = enumCheck(Class1.Struct1.Val4, val); + + val = 0; + val = enumCheck(Class1.Struct1.Enum14_Val1, 3141); + val = enumCheck(Class1.Struct1.Enum14_Val2, 3142); + val = enumCheck(Class1.Struct1.Enum14_Val3, val); + val = enumCheck(Class1.Struct1.Enum14_Val4, val); + val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141); + val = enumCheck(Class1.Struct1.Enum14_Val6g, val); + + val = 0; + val = enumCheck(Class2.Enum12_Val1, 2121); + val = enumCheck(Class2.Enum12_Val2, 2122); + val = enumCheck(Class2.Enum12_Val3, val); + val = enumCheck(Class2.Enum12_Val4, val); + val = enumCheck(Class2.Enum12_Val5h, 2121); + val = enumCheck(Class2.Enum12_Val6h, val); + + val = 0; + val = enumCheck(Class2.Val1, 2131); + val = enumCheck(Class2.Val2, 2132); + val = enumCheck(Class2.Val3, val); + val = enumCheck(Class2.Val4, val); + val = enumCheck(Class2.Val5i, 2131); + val = enumCheck(Class2.Val6i, val); + + val = 0; + val = enumCheck(Class2.Enum14_Val1, 2141); + val = enumCheck(Class2.Enum14_Val2, 2142); + val = enumCheck(Class2.Enum14_Val3, val); + val = enumCheck(Class2.Enum14_Val4, val); + val = enumCheck(Class2.Enum14_Val5j, 2141); + val = enumCheck(Class2.Enum14_Val6j, val); + + val = 0; + val = enumCheck(Class2.Struct1.Enum12_Val1, 4121); + val = enumCheck(Class2.Struct1.Enum12_Val2, 4122); + val = enumCheck(Class2.Struct1.Enum12_Val3, val); + val = enumCheck(Class2.Struct1.Enum12_Val4, val); + val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121); + val = enumCheck(Class2.Struct1.Enum12_Val6k, val); + + val = 0; + val = enumCheck(Class2.Struct1.Val1, 4131); + val = enumCheck(Class2.Struct1.Val2, 4132); + val = enumCheck(Class2.Struct1.Val3, val); + val = enumCheck(Class2.Struct1.Val4, val); + val = enumCheck(Class2.Struct1.Val5l, 4131); + val = enumCheck(Class2.Struct1.Val6l, val); + + val = 0; + val = enumCheck(Class2.Struct1.Enum14_Val1, 4141); + val = enumCheck(Class2.Struct1.Enum14_Val2, 4142); + val = enumCheck(Class2.Struct1.Enum14_Val3, val); + val = enumCheck(Class2.Struct1.Enum14_Val4, val); + val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141); + val = enumCheck(Class2.Struct1.Enum14_Val6m, val); + + Class1 class1 = new Class1(); + enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13); + enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121); + enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121); + + enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest1(cpp11_strongly_typed_enumerations_simple.Enum1_Val5a), 13); + enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest2(Class1.Enum12_Val5c), 1121); + enumCheck(cpp11_strongly_typed_enumerations_simple.globalTest3(Class1.Struct1.Enum12_Val5f), 3121); + } +} diff --git a/Examples/test-suite/java/director_nested_class_runme.java b/Examples/test-suite/java/director_nested_class_runme.java new file mode 100644 index 000000000..5144413b7 --- /dev/null +++ b/Examples/test-suite/java/director_nested_class_runme.java @@ -0,0 +1,41 @@ + +import director_nested_class.*; + +public class director_nested_class_runme { + + static { + try { + System.loadLibrary("director_nested_class"); + } 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[]) { + + director_nested_class_Derived d = new director_nested_class_Derived(); + + if (DirectorOuter.callMethod(d, 999) != 9990) { + throw new RuntimeException("callMethod(999) failed"); + } + + director_nested_class_DerivedInnerInner dinner = new director_nested_class_DerivedInnerInner(); + + if (DirectorOuter.callInnerInnerMethod(dinner, 999) != 999000) { + throw new RuntimeException("callMethod(999) failed"); + } + } +} + +class director_nested_class_Derived extends DirectorOuter.DirectorInner { + public int vmethod(int input) { + return input * 10; + } +} + +class director_nested_class_DerivedInnerInner extends DirectorOuter.DirectorInner.DirectorInnerInner { + public int innervmethod(int input) { + return input * 1000; + } +} diff --git a/Examples/test-suite/java/java_director_runme.java b/Examples/test-suite/java/java_director_runme.java index 812e791f4..2167d2621 100644 --- a/Examples/test-suite/java/java_director_runme.java +++ b/Examples/test-suite/java/java_director_runme.java @@ -53,7 +53,7 @@ public class java_director_runme { }; int actualCount = Quux.instances(); if (actualCount != expectedCount) - throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount); + System.err.println("GC failed to run (java_director). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't } /* Test Quux1's director disconnect method rename */ diff --git a/Examples/test-suite/java/java_lib_various_runme.java b/Examples/test-suite/java/java_lib_various_runme.java index 203a30ec2..6d9e13e31 100644 --- a/Examples/test-suite/java/java_lib_various_runme.java +++ b/Examples/test-suite/java/java_lib_various_runme.java @@ -83,6 +83,25 @@ public class java_lib_various_runme { if (byjove[i] != b[i]) throw new RuntimeException("By jove, it failed: [" + new String(b) + "]"); } + + // NIOBUFFER typemap check + java.nio.ByteBuffer buf = java.nio.ByteBuffer.allocateDirect(10); + java_lib_various.niobuffer_fill_hello(buf); + if ( + (char)buf.get(0) != 'h' || + (char)buf.get(1) != 'e' || + (char)buf.get(2) != 'l' || + (char)buf.get(3) != 'l' || + (char)buf.get(4) != 'o' + ) + throw new RuntimeException( + "nio test failed: " + + (char)buf.get(0) + + (char)buf.get(1) + + (char)buf.get(2) + + (char)buf.get(3) + + (char)buf.get(4) + ); } } diff --git a/Examples/test-suite/java/kwargs_feature_runme.java b/Examples/test-suite/java/kwargs_feature_runme.java new file mode 100644 index 000000000..ba742d9ec --- /dev/null +++ b/Examples/test-suite/java/kwargs_feature_runme.java @@ -0,0 +1,23 @@ +import kwargs_feature.*; + +public class kwargs_feature_runme { + + static { + try { + System.loadLibrary("kwargs_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 main(String argv[]) { + // Check normal overloading still works (no compactdefaultargs) if the kwargs feature is used, + // as the kwargs feature is not supported + Foo f = new Foo(99); + if (f.foo() != 1) + throw new RuntimeException("It went wrong"); + if (Foo.statfoo(2) != 2) + throw new RuntimeException("It went wrong"); + } +} diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java index 530008a87..750ec5067 100644 --- a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java +++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java @@ -33,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 { @@ -78,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"); @@ -671,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); } } diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java index aa355c86a..64c356f8e 100644 --- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java +++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java @@ -59,7 +59,7 @@ public class li_boost_shared_ptr_runme { } int actualCount = Klass.getTotal_count(); if (actualCount != expectedCount) - throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount); + System.err.println("GC failed to run (li_boost_shared_ptr). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't } int wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count(); diff --git a/Examples/test-suite/java/li_std_auto_ptr_runme.java b/Examples/test-suite/java/li_std_auto_ptr_runme.java index db34fb529..50ed113a4 100644 --- a/Examples/test-suite/java/li_std_auto_ptr_runme.java +++ b/Examples/test-suite/java/li_std_auto_ptr_runme.java @@ -43,7 +43,7 @@ public class li_std_auto_ptr_runme { } int actualCount = Klass.getTotal_count(); if (actualCount != expectedCount) - throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount); + System.err.println("GC failed to run (li_std_auto_ptr 1). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't } if (!k2.getLabel().equals("second")) @@ -62,7 +62,7 @@ public class li_std_auto_ptr_runme { }; int actualCount = Klass.getTotal_count(); if (actualCount != expectedCount) - throw new RuntimeException("Expected count: " + expectedCount + " Actual count: " + actualCount); + System.err.println("GC failed to run (li_std_auto_ptr 2). Expected count: " + expectedCount + " Actual count: " + actualCount); // Finalizers are not guaranteed to be run and sometimes they just don't } } } diff --git a/Examples/test-suite/java/nested_extend_c_runme.java b/Examples/test-suite/java/nested_extend_c_runme.java new file mode 100644 index 000000000..5d9d861da --- /dev/null +++ b/Examples/test-suite/java/nested_extend_c_runme.java @@ -0,0 +1,45 @@ +import nested_extend_c.*; + +public class nested_extend_c_runme { + + static { + try { + System.loadLibrary("nested_extend_c"); + } 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 + { + { + hiA hi = new hiA(); + if (hi.hi_extend() != 'h') + throw new RuntimeException("test failed"); + } + { + lowA low = new lowA(); + if (low.low_extend() != 99) + throw new RuntimeException("test failed"); + } + + { + hiB hi = new hiB(); + if (hi.hi_extend() != 'h') + throw new RuntimeException("test failed"); + } + { + lowB low = new lowB(); + if (low.low_extend() != 99) + throw new RuntimeException("test failed"); + } + { + FOO_bar foobar = new FOO_bar(); + foobar.setD(1234); + if (foobar.getD() != 1234) + throw new RuntimeException("test failed"); + foobar.bar_extend(); + } + } +} diff --git a/Examples/test-suite/java/nested_template_base_runme.java b/Examples/test-suite/java/nested_template_base_runme.java new file mode 100644 index 000000000..8404afe04 --- /dev/null +++ b/Examples/test-suite/java/nested_template_base_runme.java @@ -0,0 +1,27 @@ +import nested_template_base.*; + +public class nested_template_base_runme { + + static { + try { + System.loadLibrary("nested_template_base"); + } 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[]) { + OuterC.InnerS ois = new OuterC.InnerS(123); + OuterC.InnerC oic = new OuterC.InnerC(); + + // Check base method is available + if (oic.outer(ois).getVal() != 123) + throw new RuntimeException("Wrong value calling outer"); + + // Check non-derived class using base class + if (oic.innerc().outer(ois).getVal() != 123) + throw new RuntimeException("Wrong value calling innerc"); + + } +} diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java index 123753fd9..7726b613b 100644 --- a/Examples/test-suite/java/preproc_line_file_runme.java +++ b/Examples/test-suite/java/preproc_line_file_runme.java @@ -13,13 +13,21 @@ public class preproc_line_file_runme { private static void test_file(String file, String suffix) throws Throwable { - String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i"; - String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i"; +// For swig-3.0.1 and earlier +// String FILENAME_WINDOWS = "Examples\\test-suite\\preproc_line_file.i"; +// String FILENAME_UNIX = "Examples/test-suite/preproc_line_file.i"; + + String FILENAME_WINDOWS2 = "Examples\\test-suite\\java\\..\\preproc_line_file.i"; + String FILENAME_UNIX2 = "Examples/test-suite/java/../preproc_line_file.i"; + + String FILENAME_WINDOWS3 = "..\\.\\..\\preproc_line_file.i"; + String FILENAME_UNIX3 = ".././../preproc_line_file.i"; // We don't test for exact equality here because the file names are relative to the build directory, which can be different from the source directory, // under Unix. But they do need to end with the same path components. - if (!file.endsWith(FILENAME_UNIX + suffix) && !file.endsWith(FILENAME_WINDOWS + suffix)) - throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX + suffix); + if (!file.endsWith(FILENAME_UNIX2 + suffix) && !file.endsWith(FILENAME_WINDOWS2 + suffix) && + !file.endsWith(FILENAME_UNIX3 + suffix) && !file.endsWith(FILENAME_WINDOWS3 + suffix)) + throw new RuntimeException("file \"" + file + "\" doesn't end with " + FILENAME_UNIX2 + suffix + " or " + FILENAME_UNIX3 + suffix); } public static void main(String argv[]) throws Throwable diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java index bb4ae2c8f..9c10dedb2 100644 --- a/Examples/test-suite/java/smart_pointer_const_overload_runme.java +++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java @@ -41,7 +41,7 @@ public class smart_pointer_const_overload_runme { Assert(f.getAccess() == MUTABLE_ACCESS); // Test static method - b.stat(); + b.statMethod(); Assert(f.getAccess() == CONST_ACCESS); diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java index 406915b82..0a6571fa8 100644 --- a/Examples/test-suite/java/template_default_class_parms_runme.java +++ b/Examples/test-suite/java/template_default_class_parms_runme.java @@ -45,6 +45,11 @@ public class template_default_class_parms_runme { foo.setTType(a); a = foo.method(a); } + + { + MapDefaults md = new MapDefaults(); + md.test_func(10, 20, new DefaultNodeType()); + } } } diff --git a/Examples/test-suite/java/template_templated_constructors_runme.java b/Examples/test-suite/java/template_templated_constructors_runme.java new file mode 100644 index 000000000..cd3f31d21 --- /dev/null +++ b/Examples/test-suite/java/template_templated_constructors_runme.java @@ -0,0 +1,26 @@ + +import template_templated_constructors.*; + +public class template_templated_constructors_runme { + + static { + try { + System.loadLibrary("template_templated_constructors"); + } 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[]) { + TConstructor1 t1 = new TConstructor1(123); + TConstructor2 t2a = new TConstructor2(); + TConstructor2 t2b = new TConstructor2(123); + + TClass1Int tc1 = new TClass1Int(123.4); + TClass2Int tc2a = new TClass2Int(); + TClass2Int tc2b = new TClass2Int(123.4); + + } +} + diff --git a/Examples/test-suite/java/template_typedef_typedef_runme.java b/Examples/test-suite/java/template_typedef_typedef_runme.java index f5f368561..5a3af0099 100644 --- a/Examples/test-suite/java/template_typedef_typedef_runme.java +++ b/Examples/test-suite/java/template_typedef_typedef_runme.java @@ -12,13 +12,13 @@ public class template_typedef_typedef_runme { } public static void main(String argv[]) { - ObjectBase ob1 = new ObjectBase(); - ob1.getBlabla1(new ObjectBase()); + Object1Base ob1 = new Object1Base(); + ob1.getBlabla1(new Object1Base()); Object2Base ob2 = new Object2Base(); ob2.getBlabla2(new Object2Base()); Factory factory = new Factory(); - factory.getBlabla3(new ObjectBase()); + factory.getBlabla3(new Object1Base()); factory.getBlabla4(new Object2Base()); } } |