PageRenderTime 51ms CodeModel.GetById 16ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/octave/li_std_set_runme.m

#
Objective C | 96 lines | 68 code | 28 blank | 0 comment | 34 complexity | fdfed79c931897c095d08c117d599a7c MD5 | raw file
 1li_std_set
 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    error
15
16i = s.__iter__()
17if i.next() != "a":
18    error
19if i.next() != "b":
20    error
21if i.next() != "c":
22    error
23
24
25b = s.begin()
26e = s.end()
27sum = ""
28while (b != e):    
29    sum = sum + b.next()
30if sum != "abc":
31    error
32
33b = s.rbegin()
34e = s.rend()
35sum = ""
36while (b != e):    
37    sum = sum  + b.next()
38
39if sum != "cba":
40    error
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    error
53if i.next() != 2:
54    error
55if i.next() != 3:
56    error
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    error
72
73
74b = s.begin()
75e = s.end()
76if e - b != 2:
77    error
78    
79m = b + 1
80if m.value() != "c":
81    error
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 sum != (1, 'hello', (1, 2)):
96    error