tests/extmod/btree1: Checks for put, seq, string print and unsupported binary op.

This commit is contained in:
Alex March 2016-09-29 16:12:31 +01:00 committed by Damien George
parent 99d62c4def
commit addd1d3db1
2 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,7 @@
try:
import btree
import uio
import uerrno
except ImportError:
print("SKIP")
import sys
@ -15,6 +16,9 @@ db[b"foo1"] = b"bar1"
db[b"foo2"] = b"bar2"
db[b"bar1"] = b"foo1"
dbstr = str(db)
print(dbstr[:7], dbstr[-1:])
print(db[b"foo2"])
try:
print(db[b"foo"])
@ -56,14 +60,30 @@ print("---")
for k, v in db.items(None, None, btree.DESC):
print((k, v))
print(db.seq(1, b"foo1"))
print(db.seq(1, b"qux"))
try:
db.seq(b"foo1")
except OSError as e:
print(e.args[0] == uerrno.EINVAL)
print(list(db.keys()))
print(list(db.values()))
for k in db:
print(k)
db.put(b"baz1", b"qux1")
print("foo1", "foo1" in db)
print("foo2", "foo2" in db)
print("baz1", "baz1" in db)
try:
print(db + db[b"foo1"])
except TypeError:
print("TypeError")
db.close()
f.close()

View File

@ -1,3 +1,4 @@
<btree >
b'bar2'
KeyError
None
@ -25,6 +26,9 @@ KeyError
(b'foo3', b'bar3')
(b'foo1', b'bar1')
(b'bar1', b'foo1')
(b'foo1', b'bar1')
None
True
[b'bar1', b'foo1', b'foo3']
[b'foo1', b'bar1', b'bar3']
b'bar1'
@ -32,3 +36,5 @@ b'foo1'
b'foo3'
foo1 True
foo2 False
baz1 True
TypeError