mirror of
https://github.com/boostorg/python.git
synced 2026-02-01 08:42:16 +00:00
Tests for container_suite instance
[SVN r1518]
This commit is contained in:
35
include/boost/python/suite/indexing/testarray.py
Executable file
35
include/boost/python/suite/indexing/testarray.py
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/python
|
||||
# -*- mode:python -*-
|
||||
#
|
||||
# Python module testarray.py
|
||||
#
|
||||
# Copyright (c) 2003 Raoul M. Gough
|
||||
#
|
||||
# This material is provided "as is", with absolutely no warranty expressed
|
||||
# or implied. Any use is at your own risk.
|
||||
#
|
||||
# Permission to use or copy this material for any purpose is hereby
|
||||
# granted without fee, provided the above notices are retained on all
|
||||
# copies. Permission to modify the material and to distribute modified
|
||||
# versions is granted, provided the above notices are retained, and a
|
||||
# notice that the material was modified is included with the above
|
||||
# copyright notice.
|
||||
#
|
||||
# History
|
||||
# =======
|
||||
# 2003/ 9/ 9 rmg File creation
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
from testsuite import Array, getArray
|
||||
|
||||
a = getArray()
|
||||
|
||||
print a[0], a[1], a[2], [x for x in a], a[0:-2], a[-1:-3:-1], a[0:54:0]
|
||||
|
||||
a[1] = 4
|
||||
|
||||
print a[0], a[1], a[2], [x for x in a], a[0:-2], a[-1:-3:-1]
|
||||
|
||||
print a[0:43]
|
||||
54
include/boost/python/suite/indexing/testmap.py
Executable file
54
include/boost/python/suite/indexing/testmap.py
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
# -*- mode:python -*-
|
||||
#
|
||||
# Python module testmap.py
|
||||
#
|
||||
# Copyright (c) 2003 Raoul M. Gough
|
||||
#
|
||||
# This material is provided "as is", with absolutely no warranty expressed
|
||||
# or implied. Any use is at your own risk.
|
||||
#
|
||||
# Permission to use or copy this material for any purpose is hereby
|
||||
# granted without fee, provided the above notices are retained on all
|
||||
# copies. Permission to modify the material and to distribute modified
|
||||
# versions is granted, provided the above notices are retained, and a
|
||||
# notice that the material was modified is included with the above
|
||||
# copyright notice.
|
||||
#
|
||||
# History
|
||||
# =======
|
||||
# 2003/ 9/ 9 rmg File creation
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
from testsuite import Map
|
||||
|
||||
m = Map()
|
||||
|
||||
m["hello"] = 1
|
||||
m["there"] = 2
|
||||
|
||||
print m["hello"], m["there"]
|
||||
|
||||
m["there"] = 3
|
||||
|
||||
print m["hello"], m["there"]
|
||||
|
||||
try:
|
||||
print [x for x in m]
|
||||
|
||||
except TypeError, e:
|
||||
print "Got semi-expected type error:", e
|
||||
pass
|
||||
|
||||
try:
|
||||
print m["nonesuch"]
|
||||
|
||||
except KeyError, e:
|
||||
print "Got expected exception:", e
|
||||
pass
|
||||
|
||||
except Exception, e:
|
||||
print "Got semi-expected exception:", e
|
||||
pass
|
||||
39
include/boost/python/suite/indexing/testvector.py
Executable file
39
include/boost/python/suite/indexing/testvector.py
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/python
|
||||
# -*- mode:python -*-
|
||||
#
|
||||
# Python module testvector.py
|
||||
#
|
||||
# Copyright (c) 2003 Raoul M. Gough
|
||||
#
|
||||
# This material is provided "as is", with absolutely no warranty expressed
|
||||
# or implied. Any use is at your own risk.
|
||||
#
|
||||
# Permission to use or copy this material for any purpose is hereby
|
||||
# granted without fee, provided the above notices are retained on all
|
||||
# copies. Permission to modify the material and to distribute modified
|
||||
# versions is granted, provided the above notices are retained, and a
|
||||
# notice that the material was modified is included with the above
|
||||
# copyright notice.
|
||||
#
|
||||
# History
|
||||
# =======
|
||||
# 2003/ 9/ 9 rmg File creation
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
from testsuite import Vector
|
||||
|
||||
v = Vector()
|
||||
|
||||
v.append(1)
|
||||
v.append(2)
|
||||
v.append(3)
|
||||
|
||||
print v[0], v[1], v[2], [x for x in v]
|
||||
|
||||
v[1] = 4
|
||||
|
||||
print v[0], v[1], v[2], [x for x in v]
|
||||
|
||||
print v[0:2]
|
||||
Reference in New Issue
Block a user