/tags/rel-1.3.35/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
2import aggregate.*;
3
4public class aggregate_runme {
5
6 static {
7 try {
8 System.loadLibrary("aggregate");
9 } catch (UnsatisfiedLinkError e) {
10 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);
11 System.exit(1);
12 }
13 }
14
15 public static void main(String argv[]) {
16
17 // Confirm that move() returns correct results under normal use
18 int result = aggregate.move(aggregate.UP);
19 if (result != aggregate.UP) throw new RuntimeException("UP failed");
20
21 result = aggregate.move(aggregate.DOWN);
22 if (result != aggregate.DOWN) throw new RuntimeException("DOWN failed");
23
24 result = aggregate.move(aggregate.LEFT);
25 if (result != aggregate.LEFT) throw new RuntimeException("LEFT failed");
26
27 result = aggregate.move(aggregate.RIGHT);
28 if (result != aggregate.RIGHT) throw new RuntimeException("RIGHT failed");
29
30 // Confirm that move() raises an exception when the contract is violated
31 try {
32 aggregate.move(0);
33 throw new RuntimeException("0 test failed");
34 }
35 catch (IllegalArgumentException e) {
36 }
37 }
38}
39