summaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/li_std_string_runme.py
blob: 1360cacb5c8cd9e6b6406db52ba68e9a5585ac37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import li_std_string

x="hello"



if li_std_string.test_ccvalue(x) != x:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_cvalue(x) != x:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_value(x) != x:
  print x, li_std_string.test_value(x)
  raise RuntimeError, "bad string mapping"

if li_std_string.test_const_reference(x) != x:
  raise RuntimeError, "bad string mapping"


s = li_std_string.string("he")
#s += "ll"
#s.append('o')
s = s + "llo"

if s != x:
  print s, x
  raise RuntimeError, "bad string mapping"

if s[1:4] != x[1:4]:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_value(s) != x:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_const_reference(s) != x:
  raise RuntimeError, "bad string mapping"

a = li_std_string.A(s)

if li_std_string.test_value(a) != x:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_const_reference(a) != x:
  raise RuntimeError, "bad string mapping"

b = li_std_string.string(" world")

s = a + b
if a + b != "hello world":
  print a + b
  raise RuntimeError, "bad string mapping"
  
if a + " world" != "hello world":
  raise RuntimeError, "bad string mapping"

if "hello" + b != "hello world":
  raise RuntimeError, "bad string mapping"

c = "hello" + b
if c.find_last_of("l") != 9:
  raise RuntimeError, "bad string mapping"
  
s = "hello world"

b = li_std_string.B("hi")

b.name = li_std_string.string("hello")
if b.name != "hello":
  raise RuntimeError, "bad string mapping"


b.a = li_std_string.A("hello")
if b.a != "hello":
  raise RuntimeError, "bad string mapping"


if li_std_string.test_value_basic1(x) != x:
  raise RuntimeError, "bad string mapping"

if li_std_string.test_value_basic2(x) != x:
  raise RuntimeError, "bad string mapping"


if li_std_string.test_value_basic3(x) != x:
  raise RuntimeError, "bad string mapping"

# Global variables
s = "initial string"
if li_std_string.cvar.GlobalString2 != "global string 2":
  raise RuntimeError, "GlobalString2 test 1"
li_std_string.cvar.GlobalString2 = s
if li_std_string.cvar.GlobalString2 != s:
  raise RuntimeError, "GlobalString2 test 2"
if li_std_string.cvar.ConstGlobalString != "const global string":
  raise RuntimeError, "ConstGlobalString test"

# Member variables
myStructure = li_std_string.Structure()
if myStructure.MemberString2 != "member string 2":
  raise RuntimeError, "MemberString2 test 1"
myStructure.MemberString2 = s
if myStructure.MemberString2 != s:
  raise RuntimeError, "MemberString2 test 2"
if myStructure.ConstMemberString != "const member string":
  raise RuntimeError, "ConstMemberString test"

if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2":
  raise RuntimeError, "StaticMemberString2 test 1"
li_std_string.cvar.Structure_StaticMemberString2 = s
if li_std_string.cvar.Structure_StaticMemberString2 != s:
  raise RuntimeError, "StaticMemberString2 test 2"
if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string":
  raise RuntimeError, "ConstStaticMemberString test"


if li_std_string.test_reference_input("hello") != "hello":
  raise RuntimeError
s = li_std_string.test_reference_inout("hello")
if s != "hellohello":
  raise RuntimeError