PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 9ms RepoModel.GetById 1ms 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
 1import li_std_wstring
 2
 3x=u"h"
 4
 5if li_std_wstring.test_wcvalue(x) != x:
 6  print li_std_wstring.test_wcvalue(x)
 7  raise RuntimeError("bad string mapping")
 8
 9x=u"hello"
10if li_std_wstring.test_ccvalue(x) != x:
11  raise RuntimeError("bad string mapping")
12
13if li_std_wstring.test_cvalue(x) != x:
14  raise RuntimeError("bad string mapping")
15
16if li_std_wstring.test_value(x) != x:
17  print x, li_std_wstring.test_value(x)
18  raise RuntimeError("bad string mapping")
19
20if li_std_wstring.test_const_reference(x) != x:
21  raise RuntimeError("bad string mapping")
22
23
24s = li_std_wstring.wstring(u"he")
25s = s + u"llo"
26
27if s != x:
28  print s, x
29  raise RuntimeError("bad string mapping")
30
31if s[1:4] != x[1:4]:
32  raise RuntimeError("bad string mapping")
33
34if li_std_wstring.test_value(s) != x:
35  raise RuntimeError("bad string mapping")
36
37if li_std_wstring.test_const_reference(s) != x:
38  raise RuntimeError("bad string mapping")
39
40a = li_std_wstring.A(s)
41
42if li_std_wstring.test_value(a) != x:
43  raise RuntimeError("bad string mapping")
44
45if li_std_wstring.test_const_reference(a) != x:
46  raise RuntimeError("bad string mapping")
47
48b = li_std_wstring.wstring(" world")
49
50if a + b != "hello world":
51  raise RuntimeError("bad string mapping")
52  
53if a + " world" != "hello world":
54  raise RuntimeError("bad string mapping")
55
56# This is expected to fail if -builtin is used
57if "hello" + b != "hello world":
58  raise RuntimeError("bad string mapping")
59
60# This is expected to fail if -builtin is used
61c = "hello" + b
62if c.find_last_of("l") != 9:
63  raise RuntimeError("bad string mapping")
64  
65s = "hello world"
66
67b = li_std_wstring.B("hi")
68
69b.name = li_std_wstring.wstring(u"hello")
70if b.name != "hello":
71  raise RuntimeError("bad string mapping")
72
73
74b.a = li_std_wstring.A("hello")
75if b.a != u"hello":
76  raise RuntimeError("bad string mapping")
77
78