PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 0ms app.codeStats 1ms

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

#
Python | 104 lines | 67 code | 37 blank | 0 comment | 13 complexity | b6cb975eb2da6454b79f91002c5b3b23 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
  7
  8if cube != std_containers.cident(cube):
  9  raise RuntimeError, "bad cident"
 10
 11
 12p = (1,2)
 13if p != std_containers.pident(p):
 14  raise RuntimeError, "bad pident"
 15
 16v = (1,2,3,4,5,6)
 17
 18if v != std_containers.vident(v):
 19  raise RuntimeError, "bad pident"
 20
 21
 22if v != std_containers.videntu(v):
 23  raise RuntimeError, "bad videntu"
 24
 25vu = std_containers.vector_ui(v)
 26if vu[2] != std_containers.videntu(vu)[2]:
 27  raise RuntimeError, "bad videntu"
 28  
 29
 30if v[0:3][1] != vu[0:3][1]:
 31  print v[0:3][1], vu[0:3][1]
 32  raise RuntimeError, "bad getslice"
 33  
 34
 35m = ((1,2,3),(2,3),(3,4))
 36if m != std_containers.midenti(m):
 37  raise RuntimeError, "bad getslice"
 38
 39mb = ((1,0,1),(1,1),(1,1))
 40if mb != std_containers.midentb(mb):
 41  raise RuntimeError, "bad getslice"
 42
 43
 44mi = std_containers.imatrix(m)
 45mc = std_containers.cmatrix(m)
 46if mi[0][1] != mc[0][1]:
 47  raise RuntimeError, "bad matrix"
 48
 49
 50map ={}
 51map['hello'] = 1
 52map['hi'] = 2
 53map['3'] = 2
 54
 55if map != std_containers.mapident(map):
 56  raise RuntimeError, "bad map"
 57
 58
 59mapc ={}
 60c1 = std_containers.C()
 61c2 = std_containers.C()
 62mapc[1] = c1.this
 63mapc[2] = c2
 64
 65std_containers.mapidentc(mapc)
 66
 67
 68vi = std_containers.vector_i((2,2,3,4))
 69
 70
 71v = (1,2)
 72v1 = std_containers.v_inout(vi)
 73vi[1], v1[1]
 74
 75v1,v2 = ((1,2),(3,4))
 76v1,v2 = std_containers.v_inout2(v1,v2)
 77
 78a1 = std_containers.A(1)
 79a2 = std_containers.A(2)
 80
 81p1 = (1,a1)
 82p2 = (2,a2)
 83v = (p1,p2)
 84v2= std_containers.pia_vident(v)
 85
 86v2[0][1].a
 87v2[1][1].a
 88
 89v3 = std_containers.vector_piA(v2)
 90
 91v3[0][1].a
 92v3[1][1].a
 93
 94s = std_containers.set_i()
 95s.append(1)
 96s.append(2)
 97s.append(3)
 98j=1
 99for i in s:
100  if i != j:
101    raise RuntimeError
102  j = j + 1
103
104