File: li_std_vector_ptr_runme.py

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (56 lines) | stat: -rw-r--r-- 1,272 bytes parent folder | download | duplicates (5)
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
from li_std_vector_ptr import *

def check(val1, val2):
    if val1 != val2:
        raise RuntimeError("Values are not the same %s %s" % (val1, val2))
ip1 = makeIntPtr(11)
ip2 = makeIntPtr(22)

vi = IntPtrVector((ip1, ip2))
check(getValueFromVector(vi, 0), 11)
check(getValueFromVector(vi, 1), 22)

vA = APtrVector([makeA(33), makeA(34)])
check(getVectorValueA(vA, 0), 33)

vB = BPtrVector([makeB(133), makeB(134)])
check(getVectorValueB(vB, 0), 133)

vC = CPtrVector([makeC(1133), makeC(1134)])
check(getVectorValueC(vC, 0), 1133)


vA = [makeA(233), makeA(234)]
check(getVectorValueA(vA, 0), 233)

vB = [makeB(333), makeB(334)]
check(getVectorValueB(vB, 0), 333)

vC = [makeC(3333), makeC(3334)]
check(getVectorValueC(vC, 0), 3333)

# mixed A and B should not be accepted
vAB = [makeA(999), makeB(999)]
try:
  check(getVectorValueA(vAB, 0), 999)
  raise RuntimeError("missed exception")
except TypeError:
  pass

b111 = makeB(111)
bNones = BPtrVector([None, b111, None])

bCount = 0
noneCount = 0
for b in bNones:
  if b == None:
    noneCount = noneCount + 1
  else:
    if b.val != 111:
      raise RuntimeError("b.val is wrong")
    bCount = bCount + 1

if bCount != 1:
  raise RuntimeError("bCount wrong")
if noneCount != 2:
  raise RuntimeError("noneCount wrong")