bind: test __getitem__

Change-Id: Ic566ca370f15206288cf493e4a586e8e996a3b93
This commit is contained in:
Sebastien Binet 2015-08-05 17:48:15 +02:00
parent 45b32c5643
commit 631a4f7d59
2 changed files with 23 additions and 0 deletions

View File

@ -146,9 +146,26 @@ print "--- testing array..."
arr = hi.GetIntArray()
print "arr:",arr
print "len(arr):",len(arr)
print "arr[0]:",arr[0]
print "arr[1]:",arr[1]
try:
print "arr[2]:", arr[2]
print "*ERROR* no exception raised!"
except Exception, err:
print "caught:",err
pass
print "--- testing slice..."
s = hi.GetIntSlice()
print "slice:",s
print "len(slice):",len(s)
print "slice[0]:",s[0]
print "slice[1]:",s[1]
try:
print "slice[2]:", s[2]
print "*ERROR* no exception raised!"
except Exception, err:
print "caught:",err
pass

View File

@ -140,9 +140,15 @@ hi.Couple{P1=hi.Person{Name="mom", Age=50}, P2=hi.Person{Name="bob", Age=51}}
--- testing array...
arr: [2]int{1, 2}
len(arr): 2
arr[0]: 1
arr[1]: 2
arr[2]: caught: array index out of range
--- testing slice...
slice: []int{1, 2}
len(slice): 2
slice[0]: 1
slice[1]: 2
slice[2]: caught: array index out of range
`)
buf := new(bytes.Buffer)
cmd = exec.Command("python2", "./test.py")