PageRenderTime 25ms CodeModel.GetById 1ms app.highlight 17ms RepoModel.GetById 2ms app.codeStats 0ms

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

#
Java | 94 lines | 80 code | 14 blank | 0 comment | 9 complexity | 640352d5a312bbed15617abed8e89578 MD5 | raw file
 1import director_wombat.*;
 2
 3public class director_wombat_runme
 4{
 5  static {
 6    try {
 7        System.loadLibrary("director_wombat");
 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[] args)
15  {
16    Bar                 b = new Bar();
17    Foo_integers        a;
18    int                 retval;
19
20    a = b.meth();
21    if ((retval = a.meth(49)) != 49) {
22      throw new RuntimeException ("Test failed: retval = " + retval + ", expected 49");
23    }
24
25    a.delete();
26
27    a = new director_wombat_Foo_integers_derived();
28    if ((retval = a.meth(62)) != 62 + 2) {
29      throw new RuntimeException ("Test failed: retval = " + retval + ", expected 62 + 2");
30    }
31
32    a.delete();
33
34    a = new director_wombat_Foo_integers_derived_2();
35    if ((retval = a.meth(37)) != 37) {
36      throw new RuntimeException ("Test failed: retval = " + retval + ", expected 37");
37    }
38
39    b.delete();
40
41    b = new director_wombat_Bar_derived_1();
42    b.foo_meth_ref(a, 0);
43    b.foo_meth_ptr(a, 1);
44    b.foo_meth_val(a, 2);
45  }
46}
47
48class director_wombat_Foo_integers_derived extends Foo_integers
49{
50  public director_wombat_Foo_integers_derived()
51  {
52    super();
53  }
54
55  public int meth(int param)
56  {
57    return param + 2;
58  }
59}
60
61class director_wombat_Foo_integers_derived_2 extends Foo_integers
62{
63  public director_wombat_Foo_integers_derived_2()
64  {
65    super();
66  }
67}
68
69class director_wombat_Bar_derived_1 extends Bar
70{
71  public director_wombat_Bar_derived_1()
72  {
73    super();
74  }
75
76  public void foo_meth_ref(Foo_integers foo_obj, int param)
77  {
78    if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
79      throw new RuntimeException ("Test failed: foo_obj in foo_meth_ref is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
80    }
81  }
82  public void foo_meth_ptr(Foo_integers foo_obj, int param)
83  {
84    if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
85      throw new RuntimeException ("Test failed: foo_obj in foo_meth_ptr is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
86    }
87  }
88  public void foo_meth_val(Foo_integers foo_obj, int param)
89  {
90    if (!(foo_obj instanceof director_wombat_Foo_integers_derived_2)) {
91      throw new RuntimeException ("Test failed: foo_obj in foo_meth_val is not director_wombat_Foo_integers_derived_2, got " + foo_obj);
92    }
93  }
94}