PageRenderTime 35ms CodeModel.GetById 19ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 156 lines | 117 code | 27 blank | 12 comment | 64 complexity | 89b77a04cbf191967f69548f10e0f871 MD5 | raw file
  1
  2
  3import template_default_arg.*;
  4
  5public class template_default_arg_runme {
  6
  7  static {
  8    try {
  9	System.loadLibrary("template_default_arg");
 10    } catch (UnsatisfiedLinkError e) {
 11      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);
 12      System.exit(1);
 13    }
 14  }
 15
 16  public static void main(String argv[]) {
 17    {
 18      Hello_int helloInt = new Hello_int();
 19      helloInt.foo(Hello_int.Hi.hi);
 20    }
 21    {
 22      X_int x = new X_int();
 23      if (x.meth(20.0, 200) != 200)
 24        throw new RuntimeException("X_int test 1 failed");
 25      if (x.meth(20) != 20)
 26        throw new RuntimeException("X_int test 2 failed");
 27      if (x.meth() != 0)
 28        throw new RuntimeException("X_int test 3 failed");
 29    }
 30
 31    {
 32      Y_unsigned y = new Y_unsigned();
 33      if (y.meth(20.0, 200) != 200)
 34        throw new RuntimeException("Y_unsigned test 1 failed");
 35      if (y.meth(20) != 20)
 36        throw new RuntimeException("Y_unsigned test 2 failed");
 37      if (y.meth() != 0)
 38        throw new RuntimeException("Y_unsigned test 3 failed");
 39    }
 40
 41    {
 42      X_longlong x = new X_longlong();
 43      x = new X_longlong(20.0);
 44      x = new X_longlong(20.0, 200L);
 45    }
 46    {
 47      X_int x = new X_int();
 48      x = new X_int(20.0);
 49      x = new X_int(20.0, 200);
 50    }
 51    {
 52      X_hello_unsigned x = new X_hello_unsigned();
 53      x = new X_hello_unsigned(20.0);
 54      x = new X_hello_unsigned(20.0, new Hello_int());
 55    }
 56    {
 57      Y_hello_unsigned y = new Y_hello_unsigned();
 58      y.meth(20.0, new Hello_int());
 59      y.meth(new Hello_int());
 60      y.meth();
 61    }
 62
 63    {
 64      Foo_Z_8 fz = new Foo_Z_8();
 65      X_Foo_Z_8 x = new X_Foo_Z_8();
 66      Foo_Z_8 fzc = x.meth(fz);
 67    }
 68
 69    // Templated functions
 70    {
 71      // plain function: int ott(Foo<int>)
 72      if (template_default_arg.ott(new Foo_int()) != 30)
 73        throw new RuntimeException("ott test 1 failed");
 74
 75      // %template(ott) ott<int, int>;
 76      if (template_default_arg.ott() != 10)
 77        throw new RuntimeException("ott test 2 failed");
 78      if (template_default_arg.ott(1) != 10)
 79        throw new RuntimeException("ott test 3 failed");
 80      if (template_default_arg.ott(1, 1) != 10)
 81        throw new RuntimeException("ott test 4 failed");
 82
 83      if (template_default_arg.ott("hi") != 20)
 84        throw new RuntimeException("ott test 5 failed");
 85      if (template_default_arg.ott("hi", 1) != 20)
 86        throw new RuntimeException("ott test 6 failed");
 87      if (template_default_arg.ott("hi", 1, 1) != 20)
 88        throw new RuntimeException("ott test 7 failed");
 89
 90      // %template(ott) ott<const char *>;
 91      if (template_default_arg.ottstring(new Hello_int(), "hi") != 40)
 92        throw new RuntimeException("ott test 8 failed");
 93
 94      if (template_default_arg.ottstring(new Hello_int()) != 40)
 95        throw new RuntimeException("ott test 9 failed");
 96
 97      // %template(ott) ott<int>;
 98      if (template_default_arg.ottint(new Hello_int(), 1) != 50)
 99        throw new RuntimeException("ott test 10 failed");
100
101      if (template_default_arg.ottint(new Hello_int()) != 50)
102        throw new RuntimeException("ott test 11 failed");
103
104      // %template(ott) ott<double>;
105      if (template_default_arg.ott(new Hello_int(), 1.0) != 60)
106        throw new RuntimeException("ott test 12 failed");
107
108      if (template_default_arg.ott(new Hello_int()) != 60)
109        throw new RuntimeException("ott test 13 failed");
110    }
111
112    // Above test in namespaces
113    {
114      // plain function: int nsott(Foo<int>)
115      if (template_default_arg.nsott(new Foo_int()) != 130)
116        throw new RuntimeException("nsott test 1 failed");
117
118      // %template(nsott) nsott<int, int>;
119      if (template_default_arg.nsott() != 110)
120        throw new RuntimeException("nsott test 2 failed");
121      if (template_default_arg.nsott(1) != 110)
122        throw new RuntimeException("nsott test 3 failed");
123      if (template_default_arg.nsott(1, 1) != 110)
124        throw new RuntimeException("nsott test 4 failed");
125
126      if (template_default_arg.nsott("hi") != 120)
127        throw new RuntimeException("nsott test 5 failed");
128      if (template_default_arg.nsott("hi", 1) != 120)
129        throw new RuntimeException("nsott test 6 failed");
130      if (template_default_arg.nsott("hi", 1, 1) != 120)
131        throw new RuntimeException("nsott test 7 failed");
132
133      // %template(nsott) nsott<const char *>;
134      if (template_default_arg.nsottstring(new Hello_int(), "hi") != 140)
135        throw new RuntimeException("nsott test 8 failed");
136
137      if (template_default_arg.nsottstring(new Hello_int()) != 140)
138        throw new RuntimeException("nsott test 9 failed");
139
140      // %template(nsott) nsott<int>;
141      if (template_default_arg.nsottint(new Hello_int(), 1) != 150)
142        throw new RuntimeException("nsott test 10 failed");
143
144      if (template_default_arg.nsottint(new Hello_int()) != 150)
145        throw new RuntimeException("nsott test 11 failed");
146
147      // %template(nsott) nsott<double>;
148      if (template_default_arg.nsott(new Hello_int(), 1.0) != 160)
149        throw new RuntimeException("nsott test 12 failed");
150
151      if (template_default_arg.nsott(new Hello_int()) != 160)
152        throw new RuntimeException("nsott test 13 failed");
153    }
154  }
155}
156