PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Examples/test-suite/python/template_default_arg_runme.py

#
Python | 98 lines | 59 code | 33 blank | 6 comment | 19 complexity | 10cb937518bd8f2a68f3dd40838908bf MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import template_default_arg
  2. helloInt = template_default_arg.Hello_int()
  3. helloInt.foo(template_default_arg.Hello_int.hi)
  4. x = template_default_arg.X_int()
  5. if (x.meth(20.0, 200) != 200):
  6. raise RuntimeError, ("X_int test 1 failed")
  7. if (x.meth(20) != 20):
  8. raise RuntimeError, ("X_int test 2 failed")
  9. if (x.meth() != 0):
  10. raise RuntimeError, ("X_int test 3 failed")
  11. y = template_default_arg.Y_unsigned()
  12. if (y.meth(20.0, 200) != 200):
  13. raise RuntimeError, ("Y_unsigned test 1 failed")
  14. if (y.meth(20) != 20):
  15. raise RuntimeError, ("Y_unsigned test 2 failed")
  16. if (y.meth() != 0):
  17. raise RuntimeError, ("Y_unsigned test 3 failed")
  18. x = template_default_arg.X_longlong()
  19. x = template_default_arg.X_longlong(20.0)
  20. x = template_default_arg.X_longlong(20.0, 200L)
  21. x = template_default_arg.X_int()
  22. x = template_default_arg.X_int(20.0)
  23. x = template_default_arg.X_int(20.0, 200)
  24. x = template_default_arg.X_hello_unsigned()
  25. x = template_default_arg.X_hello_unsigned(20.0)
  26. x = template_default_arg.X_hello_unsigned(20.0, template_default_arg.Hello_int())
  27. y = template_default_arg.Y_hello_unsigned()
  28. y.meth(20.0, template_default_arg.Hello_int())
  29. y.meth(template_default_arg.Hello_int())
  30. y.meth()
  31. fz = template_default_arg.Foo_Z_8()
  32. x = template_default_arg.X_Foo_Z_8()
  33. fzc = x.meth(fz)
  34. # Templated functions
  35. # plain function: int ott(Foo<int>)
  36. if (template_default_arg.ott(template_default_arg.Foo_int()) != 30):
  37. raise RuntimeError, ("ott test 1 failed")
  38. # %template(ott) ott<int, int>
  39. if (template_default_arg.ott() != 10):
  40. raise RuntimeError, ("ott test 2 failed")
  41. if (template_default_arg.ott(1) != 10):
  42. raise RuntimeError, ("ott test 3 failed")
  43. if (template_default_arg.ott(1, 1) != 10):
  44. raise RuntimeError, ("ott test 4 failed")
  45. if (template_default_arg.ott("hi") != 20):
  46. raise RuntimeError, ("ott test 5 failed")
  47. if (template_default_arg.ott("hi", 1) != 20):
  48. raise RuntimeError, ("ott test 6 failed")
  49. if (template_default_arg.ott("hi", 1, 1) != 20):
  50. raise RuntimeError, ("ott test 7 failed")
  51. # %template(ott) ott<const char *>
  52. if (template_default_arg.ottstring(template_default_arg.Hello_int(), "hi") != 40):
  53. raise RuntimeError, ("ott test 8 failed")
  54. if (template_default_arg.ottstring(template_default_arg.Hello_int()) != 40):
  55. raise RuntimeError, ("ott test 9 failed")
  56. # %template(ott) ott<int>
  57. if (template_default_arg.ottint(template_default_arg.Hello_int(), 1) != 50):
  58. raise RuntimeError, ("ott test 10 failed")
  59. if (template_default_arg.ottint(template_default_arg.Hello_int()) != 50):
  60. raise RuntimeError, ("ott test 11 failed")
  61. # %template(ott) ott<double>
  62. if (template_default_arg.ott(template_default_arg.Hello_int(), 1.0) != 60):
  63. raise RuntimeError, ("ott test 12 failed")
  64. if (template_default_arg.ott(template_default_arg.Hello_int()) != 60):
  65. raise RuntimeError, ("ott test 13 failed")