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