enum runtime test
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4382 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
792b701599
commit
3f2ca63453
1 changed files with 40 additions and 0 deletions
40
Examples/test-suite/java/java_enums_runme.java
Normal file
40
Examples/test-suite/java/java_enums_runme.java
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
|
||||||
|
import java_enums.*;
|
||||||
|
|
||||||
|
public class java_enums_runme {
|
||||||
|
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 java_enums.FIDDLE:
|
||||||
|
break;
|
||||||
|
case java_enums.STICKS:
|
||||||
|
break;
|
||||||
|
case java_enums.BONGO:
|
||||||
|
break;
|
||||||
|
case java_enums.DRUMS:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (java_enums.DRUMS != 15)
|
||||||
|
throw new RuntimeException("Incorrect value for DRUMS");
|
||||||
|
|
||||||
|
// check typemaps use short for this enum
|
||||||
|
short nonsense = java_enums.POPPYCOCK;
|
||||||
|
short tst1 = java_enums.test1(nonsense);
|
||||||
|
short tst2 = java_enums.test2(nonsense);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue