PageRenderTime 57ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1.3.35/Examples/test-suite/python/li_std_string_runme.py

#
Python | 132 lines | 90 code | 38 blank | 4 comment | 31 complexity | ad75d2063e6105fd0315f4920b304103 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import li_std_string
  2. x="hello"
  3. if li_std_string.test_ccvalue(x) != x:
  4. raise RuntimeError, "bad string mapping"
  5. if li_std_string.test_cvalue(x) != x:
  6. raise RuntimeError, "bad string mapping"
  7. if li_std_string.test_value(x) != x:
  8. print x, li_std_string.test_value(x)
  9. raise RuntimeError, "bad string mapping"
  10. if li_std_string.test_const_reference(x) != x:
  11. raise RuntimeError, "bad string mapping"
  12. s = li_std_string.string("he")
  13. #s += "ll"
  14. #s.append('o')
  15. s = s + "llo"
  16. if s != x:
  17. print s, x
  18. raise RuntimeError, "bad string mapping"
  19. if s[1:4] != x[1:4]:
  20. raise RuntimeError, "bad string mapping"
  21. if li_std_string.test_value(s) != x:
  22. raise RuntimeError, "bad string mapping"
  23. if li_std_string.test_const_reference(s) != x:
  24. raise RuntimeError, "bad string mapping"
  25. a = li_std_string.A(s)
  26. if li_std_string.test_value(a) != x:
  27. raise RuntimeError, "bad string mapping"
  28. if li_std_string.test_const_reference(a) != x:
  29. raise RuntimeError, "bad string mapping"
  30. b = li_std_string.string(" world")
  31. s = a + b
  32. if a + b != "hello world":
  33. print a + b
  34. raise RuntimeError, "bad string mapping"
  35. if a + " world" != "hello world":
  36. raise RuntimeError, "bad string mapping"
  37. if "hello" + b != "hello world":
  38. raise RuntimeError, "bad string mapping"
  39. c = "hello" + b
  40. if c.find_last_of("l") != 9:
  41. raise RuntimeError, "bad string mapping"
  42. s = "hello world"
  43. b = li_std_string.B("hi")
  44. b.name = li_std_string.string("hello")
  45. if b.name != "hello":
  46. raise RuntimeError, "bad string mapping"
  47. b.a = li_std_string.A("hello")
  48. if b.a != "hello":
  49. raise RuntimeError, "bad string mapping"
  50. if li_std_string.test_value_basic1(x) != x:
  51. raise RuntimeError, "bad string mapping"
  52. if li_std_string.test_value_basic2(x) != x:
  53. raise RuntimeError, "bad string mapping"
  54. if li_std_string.test_value_basic3(x) != x:
  55. raise RuntimeError, "bad string mapping"
  56. # Global variables
  57. s = "initial string"
  58. if li_std_string.cvar.GlobalString2 != "global string 2":
  59. raise RuntimeError, "GlobalString2 test 1"
  60. li_std_string.cvar.GlobalString2 = s
  61. if li_std_string.cvar.GlobalString2 != s:
  62. raise RuntimeError, "GlobalString2 test 2"
  63. if li_std_string.cvar.ConstGlobalString != "const global string":
  64. raise RuntimeError, "ConstGlobalString test"
  65. # Member variables
  66. myStructure = li_std_string.Structure()
  67. if myStructure.MemberString2 != "member string 2":
  68. raise RuntimeError, "MemberString2 test 1"
  69. myStructure.MemberString2 = s
  70. if myStructure.MemberString2 != s:
  71. raise RuntimeError, "MemberString2 test 2"
  72. if myStructure.ConstMemberString != "const member string":
  73. raise RuntimeError, "ConstMemberString test"
  74. if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2":
  75. raise RuntimeError, "StaticMemberString2 test 1"
  76. li_std_string.cvar.Structure_StaticMemberString2 = s
  77. if li_std_string.cvar.Structure_StaticMemberString2 != s:
  78. raise RuntimeError, "StaticMemberString2 test 2"
  79. if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string":
  80. raise RuntimeError, "ConstStaticMemberString test"
  81. if li_std_string.test_reference_input("hello") != "hello":
  82. raise RuntimeError
  83. s = li_std_string.test_reference_inout("hello")
  84. if s != "hellohello":
  85. raise RuntimeError
  86. if li_std_string.empty() != "":
  87. raise RuntimeError
  88. if li_std_string.c_empty() != "":
  89. raise RuntimeError
  90. if li_std_string.c_null() != None:
  91. raise RuntimeError