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