/tags/rel-1-3-29/SWIG/Examples/test-suite/python/std_containers_runme.py

#
Python | 119 lines | 81 code | 38 blank | 0 comment | 29 complexity | 7111048f778b1c8e4f6e4faf91da0283 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
```  1import sys
2import std_containers
3
4
5cube = (((1, 2), (3, 4)), ((5, 6), (7, 8)))
6
7icube = std_containers.cident(cube)
8for i in range(0,len(cube)):
9  if cube[i] != icube[i]:
11
12
13p = (1,2)
14if p != std_containers.pident(p):
16
17v = (1,2,3,4,5,6)
18iv = std_containers.vident(v)
19for i in range(0,len(v)):
20  if v[i] != iv[i]:
22
23
24
25iv = std_containers.videntu(v)
26for i in range(0,len(v)):
27  if v[i] != iv[i]:
29
30
31vu = std_containers.vector_ui(v)
32if vu[2] != std_containers.videntu(vu)[2]:
34
35
36if v[0:3][1] != vu[0:3][1]:
37  print v[0:3][1], vu[0:3][1]
39
40
41m = ((1,2,3),(2,3),(3,4))
42im = std_containers.midenti(m)
43
44for i in range(0,len(m)):
45  for j in range(0,len(m[i])):
46    if m[i][j] != im[i][j]:
48
49m = ((1,0,1),(1,1),(1,1))
50im = std_containers.midentb(m)
51for i in range(0,len(m)):
52  for j in range(0,len(m[i])):
53    if m[i][j] != im[i][j]:
55
56
57mi = std_containers.imatrix(m)
58mc = std_containers.cmatrix(m)
59if mi[0][1] != mc[0][1]:
61
62
63map ={}
64map['hello'] = 1
65map['hi'] = 2
66map['3'] = 2
67
68imap = std_containers.mapident(map)
69for k in map:
70  if map[k] != imap[k]:
72
73
74mapc ={}
75c1 = std_containers.C()
76c2 = std_containers.C()
77mapc[1] = c1.this
78mapc[2] = c2
79
80std_containers.mapidentc(mapc)
81
82
83vi = std_containers.vector_i((2,2,3,4))
84
85
86v = (1,2)
87v1 = std_containers.v_inout(vi)
88vi[1], v1[1]
89
90v1,v2 = ((1,2),(3,4))
91v1,v2 = std_containers.v_inout2(v1,v2)
92
93a1 = std_containers.A(1)
94a2 = std_containers.A(2)
95
96p1 = (1,a1)
97p2 = (2,a2)
98v = (p1,p2)
99v2= std_containers.pia_vident(v)
100
101v2[0][1].a
102v2[1][1].a
103
104v3 = std_containers.vector_piA(v2)
105
106v3[0][1].a
107v3[1][1].a
108
109s = std_containers.set_i()
110s.append(1)
111s.append(2)
112s.append(3)
113j=1
114for i in s:
115  if i != j:
116    raise RuntimeError
117  j = j + 1
118
119
```