PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import friends.*;
  2. public class friends_runme {
  3. static {
  4. try {
  5. System.loadLibrary("friends");
  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[]) throws Throwable
  12. {
  13. A a = new A(2);
  14. if (friends.get_val1(a) != 2)
  15. throw new RuntimeException("failed");
  16. if (friends.get_val2(a) != 4)
  17. throw new RuntimeException("failed");
  18. if (friends.get_val3(a) != 6)
  19. throw new RuntimeException("failed");
  20. // nice overload working fine
  21. if (friends.get_val1(1,2,3) != 1)
  22. throw new RuntimeException("failed");
  23. B b = new B(3);
  24. // David's case
  25. if (friends.mix(a,b) != 5)
  26. throw new RuntimeException("failed");
  27. D_d di = new D_d(2);
  28. D_d dd = new D_d(3.3);
  29. // incredible template overloading working just fine
  30. if (friends.get_val1(di) != 2)
  31. throw new RuntimeException("failed");
  32. if (friends.get_val1(dd) != 3.3)
  33. throw new RuntimeException("failed");
  34. friends.set(di, 4);
  35. friends.set(dd, 1.3);
  36. if (friends.get_val1(di) != 4)
  37. throw new RuntimeException("failed");
  38. if (friends.get_val1(dd) != 1.3)
  39. throw new RuntimeException("failed");
  40. }
  41. }