/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
1import li_std_string
2
3x="hello"
4
5
6
7if li_std_string.test_ccvalue(x) != x:
8 raise RuntimeError, "bad string mapping"
9
10if li_std_string.test_cvalue(x) != x:
11 raise RuntimeError, "bad string mapping"
12
13if li_std_string.test_value(x) != x:
14 print x, li_std_string.test_value(x)
15 raise RuntimeError, "bad string mapping"
16
17if li_std_string.test_const_reference(x) != x:
18 raise RuntimeError, "bad string mapping"
19
20
21s = li_std_string.string("he")
22#s += "ll"
23#s.append('o')
24s = s + "llo"
25
26if s != x:
27 print s, x
28 raise RuntimeError, "bad string mapping"
29
30if s[1:4] != x[1:4]:
31 raise RuntimeError, "bad string mapping"
32
33if li_std_string.test_value(s) != x:
34 raise RuntimeError, "bad string mapping"
35
36if li_std_string.test_const_reference(s) != x:
37 raise RuntimeError, "bad string mapping"
38
39a = li_std_string.A(s)
40
41if li_std_string.test_value(a) != x:
42 raise RuntimeError, "bad string mapping"
43
44if li_std_string.test_const_reference(a) != x:
45 raise RuntimeError, "bad string mapping"
46
47b = li_std_string.string(" world")
48
49s = a + b
50if a + b != "hello world":
51 print a + b
52 raise RuntimeError, "bad string mapping"
53
54if a + " world" != "hello world":
55 raise RuntimeError, "bad string mapping"
56
57if "hello" + b != "hello world":
58 raise RuntimeError, "bad string mapping"
59
60c = "hello" + b
61if c.find_last_of("l") != 9:
62 raise RuntimeError, "bad string mapping"
63
64s = "hello world"
65
66b = li_std_string.B("hi")
67
68b.name = li_std_string.string("hello")
69if b.name != "hello":
70 raise RuntimeError, "bad string mapping"
71
72
73b.a = li_std_string.A("hello")
74if b.a != "hello":
75 raise RuntimeError, "bad string mapping"
76
77
78if li_std_string.test_value_basic1(x) != x:
79 raise RuntimeError, "bad string mapping"
80
81if li_std_string.test_value_basic2(x) != x:
82 raise RuntimeError, "bad string mapping"
83
84
85if li_std_string.test_value_basic3(x) != x:
86 raise RuntimeError, "bad string mapping"
87
88# Global variables
89s = "initial string"
90if li_std_string.cvar.GlobalString2 != "global string 2":
91 raise RuntimeError, "GlobalString2 test 1"
92li_std_string.cvar.GlobalString2 = s
93if li_std_string.cvar.GlobalString2 != s:
94 raise RuntimeError, "GlobalString2 test 2"
95if li_std_string.cvar.ConstGlobalString != "const global string":
96 raise RuntimeError, "ConstGlobalString test"
97
98# Member variables
99myStructure = li_std_string.Structure()
100if myStructure.MemberString2 != "member string 2":
101 raise RuntimeError, "MemberString2 test 1"
102myStructure.MemberString2 = s
103if myStructure.MemberString2 != s:
104 raise RuntimeError, "MemberString2 test 2"
105if myStructure.ConstMemberString != "const member string":
106 raise RuntimeError, "ConstMemberString test"
107
108if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2":
109 raise RuntimeError, "StaticMemberString2 test 1"
110li_std_string.cvar.Structure_StaticMemberString2 = s
111if li_std_string.cvar.Structure_StaticMemberString2 != s:
112 raise RuntimeError, "StaticMemberString2 test 2"
113if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string":
114 raise RuntimeError, "ConstStaticMemberString test"
115
116
117if li_std_string.test_reference_input("hello") != "hello":
118 raise RuntimeError
119s = li_std_string.test_reference_inout("hello")
120if s != "hellohello":
121 raise RuntimeError
122
123
124if li_std_string.empty() != "":
125 raise RuntimeError
126
127
128if li_std_string.c_empty() != "":
129 raise RuntimeError
130
131if li_std_string.c_null() != None:
132 raise RuntimeError