PageRenderTime 40ms CodeModel.GetById 21ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 52 lines | 46 code | 6 blank | 0 comment | 2 complexity | ee4d1082d6fa46ad940febf3fcea59a7 MD5 | raw file
 1import extend_constructor_destructor.*;
 2
 3public class extend_constructor_destructor_runme {
 4
 5  static {
 6    try {
 7	System.loadLibrary("extend_constructor_destructor");
 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    AStruct a = new AStruct(10);
16    checkGlobal(10);
17    BStruct b = new BStruct(20);
18    checkGlobal(20);
19    CStruct c = new CStruct(30);
20    checkGlobal(30);
21    DStruct d = new DStruct(40);
22    checkGlobal(40);
23    EStruct e = new EStruct(50);
24    checkGlobal(50);
25    FStruct f = new FStruct(60);
26    checkGlobal(60);
27    GStruct g = new GStruct(70);
28    checkGlobal(70);
29
30    a.delete();
31    checkGlobal(-10);
32    b.delete();
33    checkGlobal(-20);
34    c.delete();
35    checkGlobal(-30);
36    d.delete();
37    checkGlobal(-40);
38    e.delete();
39    checkGlobal(-50);
40    f.delete();
41    checkGlobal(-60);
42    g.delete();
43    checkGlobal(-70);
44  }
45
46  public static void checkGlobal(int val) {
47    int global = extend_constructor_destructor.getGlobalVar();
48    if (global != val)
49      throw new RuntimeException("global value incorrect. Expected: " + val + " got: " + global);
50  }
51}
52