PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/java/java_enums_runme.java

#
Java | 54 lines | 44 code | 6 blank | 4 comment | 2 complexity | fe9c260514713447acab7560f718b720 MD5 | raw file
 1
 2import java_enums.*;
 3
 4public class java_enums_runme implements stuff {
 5  static {
 6    try {
 7        System.loadLibrary("java_enums");
 8    } catch (UnsatisfiedLinkError e) {
 9      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);
10      System.exit(1);
11    }
12  }
13
14  public static void main(String argv[]) 
15  {
16      int number = 200;
17
18      // Switch statement will only compile if these enums are initialised 
19      // from a constant Java value, that is not from a function call
20      switch(number) {
21          case stuff.FIDDLE:
22              break;
23          case stuff.STICKS:
24              break;
25          case stuff.BONGO:
26              break;
27          case stuff.DRUMS:
28              break;
29          default:
30              break;
31      }
32      if (stuff.DRUMS != 15)
33          throw new RuntimeException("Incorrect value for DRUMS");
34
35      // check typemaps use short for this enum
36      short poppycock = nonsense.POPPYCOCK;
37      short tst1 = java_enums.test1(poppycock);
38      short tst2 = java_enums.test2(poppycock);
39
40      // Check that stuff is an interface and not a class - we can drop the stuff keyword as this class implements the stuff interface
41      switch(number) {
42          case FIDDLE:
43              break;
44          case STICKS:
45              break;
46          case BONGO:
47              break;
48          case DRUMS:
49              break;
50          default:
51              break;
52      }
53  }
54}