PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 33 lines | 19 code | 9 blank | 5 comment | 4 complexity | 16e76ec996caa4be8cbb8cbae312e5db MD5 | raw file
 1
 2// This is the ret_by_value runtime testcase. It checks that SWIG handles
 3// return by value okay.
 4
 5import ret_by_value.*;
 6
 7public class ret_by_value_runme {
 8
 9  static {
10    try {
11	System.loadLibrary("ret_by_value");
12    } catch (UnsatisfiedLinkError e) {
13      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);
14      System.exit(1);
15    }
16  }
17
18  public static void main(String argv[]) {
19
20    // Get the test class. Note that this constructor will ensure that the memory created 
21    // in the wrapper is owned by the test class.
22    test tst = ret_by_value.get_test();
23
24    if (tst.getMyInt() != 100 || tst.getMyShort() != 200) {
25      System.err.println("Runtime test failed. myInt=" + tst.getMyInt() + " myShort=" + tst.getMyShort());
26      System.exit(1);
27    }
28
29    // Delete memory manually, it should not be deleted again by the test class finalizer
30    tst.delete();
31  }
32}
33