PageRenderTime 47ms CodeModel.GetById 39ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 53 lines | 38 code | 12 blank | 3 comment | 18 complexity | c150d56363db9219f0893f7a3ddfdb60 MD5 | raw file
 1import friends.*;
 2
 3public class friends_runme {
 4
 5  static {
 6    try {
 7        System.loadLibrary("friends");
 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[]) throws Throwable
15  {
16    A a = new A(2);
17
18    if (friends.get_val1(a) != 2)
19      throw new RuntimeException("failed");
20    if (friends.get_val2(a) != 4)
21      throw new RuntimeException("failed");
22    if (friends.get_val3(a) != 6)
23      throw new RuntimeException("failed");
24
25    // nice overload working fine
26    if (friends.get_val1(1,2,3) != 1)
27      throw new RuntimeException("failed");
28
29    B b = new B(3);
30
31    // David's case
32    if (friends.mix(a,b) != 5)
33      throw new RuntimeException("failed");
34
35    D_d di = new D_d(2);
36    D_d dd = new D_d(3.3);
37
38    // incredible template overloading working just fine
39    if (friends.get_val1(di) != 2)
40      throw new RuntimeException("failed");
41    if (friends.get_val1(dd) != 3.3)
42      throw new RuntimeException("failed");
43
44    friends.set(di, 4);
45    friends.set(dd, 1.3);
46
47    if (friends.get_val1(di) != 4)
48      throw new RuntimeException("failed");
49    if (friends.get_val1(dd) != 1.3)
50      throw new RuntimeException("failed");
51  }
52}
53