File: li_std_vector_runme.py

package info (click to toggle)
swig1.3 1.3.24-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 19,336 kB
  • ctags: 10,604
  • sloc: cpp: 27,917; ansic: 24,160; yacc: 4,412; python: 4,255; java: 4,156; makefile: 3,735; sh: 3,552; cs: 2,250; ruby: 2,150; lisp: 1,605; tcl: 1,136; perl: 980; php: 879; ml: 825
file content (91 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download
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
from li_std_vector import *

iv = IntVector(4)
for i in range(0,4):
    iv[i] = i

x = average(iv)
y = average([1,2,3,4])

a = half([10,10.5,11,11.5])

dv = DoubleVector(10)
for i in range(0,10):
    dv[i] = i/2.0

halve_in_place(dv)


bv = BoolVector(4)
bv[0]= 1
bv[1]= 0
bv[2]= 4
bv[3]= 0

if bv[0] != bv[2]:
    raise RuntimeError,"bad std::vector<bool> mapping"

b = B(5)
va = VecA([b,None,b,b])

if va[0].f(1) != 6:
    raise RuntimeError,"bad std::vector<A*> mapping"

if vecAptr(va) != 6:
    raise RuntimeError,"bad std::vector<A*> mapping"

b.val = 7
if va[3].f(1) != 8:
    raise RuntimeError,"bad std::vector<A*> mapping"


ip = PtrInt()
ap = new_ArrInt(10)

ArrInt_setitem(ip,0,123)
ArrInt_setitem(ap,2,123)

vi = IntPtrVector((ip,ap,None))
if ArrInt_getitem(vi[0],0) != ArrInt_getitem(vi[1],2):
    raise RuntimeError,"bad std::vector<int*> mapping"
    


a = halfs([10,8,4,3])

v = IntVector()
v[0:2] = [1,2]
if v[0] != 1 or v[1] != 2:
    raise RuntimeError,"bad setslice"

if v[0:-1][0] != 1:
    raise RuntimeError,"bad getslice"

if v[0:-2].size() != 0:
    raise RuntimeError,"bad getslice"

v[0:1] = [2]
if v[0] != 2:
    raise RuntimeError,"bad setslice"

v[1:] = [3]
if v[1] != 3:
    raise RuntimeError,"bad setslice"

v[2:] = [3]
if v[2] != 3:
    raise RuntimeError,"bad setslice"

if v[0:][0] != v[0]:
    raise RuntimeError,"bad getslice"


del v[:]
if v.size() != 0:
    raise RuntimeError,"bad getslice"    

del v[:]
if v.size() != 0:
    raise RuntimeError,"bad getslice"