import source from 1.3.40
[external/swig.git] / Examples / test-suite / java / aggregate_runme.java
1
2 import aggregate.*;
3
4 public 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