PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Python | 96 lines | 93 code | 3 blank | 0 comment | 0 complexity | 0e9c15648bfb5c254b8b850a1879c6dc MD5 | raw file
 1from li_std_set import *
 2
 3s = set_string()
 4
 5s.append("a")
 6s.append("b")
 7s.append("c")
 8
 9sum = ""
10for i in s:
11    sum = sum + i
12
13if sum != "abc":
14    raise RuntimeError
15
16i = s.__iter__()
17if i.next() != "a":
18    raise RuntimeError
19if i.next() != "b":
20    raise RuntimeError
21if i.next() != "c":
22    raise RuntimeError
23
24
25b = s.begin()
26e = s.end()
27sum = ""
28while (b != e):    
29    sum = sum + b.next()
30if sum != "abc":
31    raise RuntimeError
32
33b = s.rbegin()
34e = s.rend()
35sum = ""
36while (b != e):    
37    sum = sum  + b.next()
38
39if sum != "cba":
40    raise RuntimeError
41
42
43
44si = set_int()
45
46si.append(1)
47si.append(2)
48si.append(3)
49i = si.__iter__()
50
51if i.next() != 1:
52    raise RuntimeError
53if i.next() != 2:
54    raise RuntimeError
55if i.next() != 3:
56    raise RuntimeError
57
58
59
60
61i = s.begin()
62i.next()
63s.erase(i)
64
65b = s.begin()
66e = s.end()
67sum = ""
68while (b != e):    
69    sum = sum + b.next()
70if sum != "ac":
71    raise RuntimeError
72
73
74b = s.begin()
75e = s.end()
76if e - b != 2:
77    raise RuntimeError
78    
79m = b + 1
80if m.value() != "c":
81    raise RuntimeError
82
83
84
85s = pyset()
86s.insert((1,2))
87s.insert(1)
88s.insert("hello")
89
90
91sum = ()
92for i in s:
93    sum = sum  + (i,)
94
95if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) :
96    raise RuntimeError