PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Java | 39 lines | 27 code | 10 blank | 2 comment | 8 complexity | bccebcaf50a8a0bda48c9f33eb672200 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import aggregate.*;
  2. public class aggregate_runme {
  3. static {
  4. try {
  5. System.loadLibrary("aggregate");
  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. // Confirm that move() returns correct results under normal use
  13. int result = aggregate.move(aggregate.UP);
  14. if (result != aggregate.UP) throw new RuntimeException("UP failed");
  15. result = aggregate.move(aggregate.DOWN);
  16. if (result != aggregate.DOWN) throw new RuntimeException("DOWN failed");
  17. result = aggregate.move(aggregate.LEFT);
  18. if (result != aggregate.LEFT) throw new RuntimeException("LEFT failed");
  19. result = aggregate.move(aggregate.RIGHT);
  20. if (result != aggregate.RIGHT) throw new RuntimeException("RIGHT failed");
  21. // Confirm that move() raises an exception when the contract is violated
  22. try {
  23. aggregate.move(0);
  24. throw new RuntimeException("0 test failed");
  25. }
  26. catch (IllegalArgumentException e) {
  27. }
  28. }
  29. }