PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
Python | 78 lines | 49 code | 27 blank | 2 comment | 17 complexity | aeca6fbda12b358e546829097f5db543 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. import li_std_wstring
  2. x=u"h"
  3. if li_std_wstring.test_wcvalue(x) != x:
  4. print li_std_wstring.test_wcvalue(x)
  5. raise RuntimeError("bad string mapping")
  6. x=u"hello"
  7. if li_std_wstring.test_ccvalue(x) != x:
  8. raise RuntimeError("bad string mapping")
  9. if li_std_wstring.test_cvalue(x) != x:
  10. raise RuntimeError("bad string mapping")
  11. if li_std_wstring.test_value(x) != x:
  12. print x, li_std_wstring.test_value(x)
  13. raise RuntimeError("bad string mapping")
  14. if li_std_wstring.test_const_reference(x) != x:
  15. raise RuntimeError("bad string mapping")
  16. s = li_std_wstring.wstring(u"he")
  17. s = s + u"llo"
  18. if s != x:
  19. print s, x
  20. raise RuntimeError("bad string mapping")
  21. if s[1:4] != x[1:4]:
  22. raise RuntimeError("bad string mapping")
  23. if li_std_wstring.test_value(s) != x:
  24. raise RuntimeError("bad string mapping")
  25. if li_std_wstring.test_const_reference(s) != x:
  26. raise RuntimeError("bad string mapping")
  27. a = li_std_wstring.A(s)
  28. if li_std_wstring.test_value(a) != x:
  29. raise RuntimeError("bad string mapping")
  30. if li_std_wstring.test_const_reference(a) != x:
  31. raise RuntimeError("bad string mapping")
  32. b = li_std_wstring.wstring(" world")
  33. if a + b != "hello world":
  34. raise RuntimeError("bad string mapping")
  35. if a + " world" != "hello world":
  36. raise RuntimeError("bad string mapping")
  37. # This is expected to fail if -builtin is used
  38. if "hello" + b != "hello world":
  39. raise RuntimeError("bad string mapping")
  40. # This is expected to fail if -builtin is used
  41. c = "hello" + b
  42. if c.find_last_of("l") != 9:
  43. raise RuntimeError("bad string mapping")
  44. s = "hello world"
  45. b = li_std_wstring.B("hi")
  46. b.name = li_std_wstring.wstring(u"hello")
  47. if b.name != "hello":
  48. raise RuntimeError("bad string mapping")
  49. b.a = li_std_wstring.A("hello")
  50. if b.a != u"hello":
  51. raise RuntimeError("bad string mapping")