diff options
Diffstat (limited to 'Examples/test-suite/java/java_enums_runme.java')
| -rw-r--r-- | Examples/test-suite/java/java_enums_runme.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/Examples/test-suite/java/java_enums_runme.java b/Examples/test-suite/java/java_enums_runme.java new file mode 100644 index 0000000..bc7d416 --- /dev/null +++ b/Examples/test-suite/java/java_enums_runme.java @@ -0,0 +1,54 @@ + +import java_enums.*; + +public class java_enums_runme implements stuff { + static { + try { + System.loadLibrary("java_enums"); + } 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[]) + { + int number = 200; + + // Switch statement will only compile if these enums are initialised + // from a constant Java value, that is not from a function call + switch(number) { + case stuff.FIDDLE: + break; + case stuff.STICKS: + break; + case stuff.BONGO: + break; + case stuff.DRUMS: + break; + default: + break; + } + if (stuff.DRUMS != 15) + throw new RuntimeException("Incorrect value for DRUMS"); + + // check typemaps use short for this enum + short poppycock = nonsense.POPPYCOCK; + short tst1 = java_enums.test1(poppycock); + short tst2 = java_enums.test2(poppycock); + + // Check that stuff is an interface and not a class - we can drop the stuff keyword as this class implements the stuff interface + switch(number) { + case FIDDLE: + break; + case STICKS: + break; + case BONGO: + break; + case DRUMS: + break; + default: + break; + } + } +} |
