Commit afb41a07 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 55032df4
...@@ -388,7 +388,7 @@ def TopoDecode(text): ...@@ -388,7 +388,7 @@ def TopoDecode(text):
if len(bottomq) != 0: if len(bottomq) != 0:
raise TopoDecodeError("level %d does not link to all nodes in the next level" % raise TopoDecodeError("level %d does not link to all nodes in the next level" %
len(levelv+1)) (len(levelv)+1,))
if len(currentv) != 1: if len(currentv) != 1:
raise TopoDecodeError("first level has %d entries; must be 1" % len(currentv)) raise TopoDecodeError("first level has %d entries; must be 1" % len(currentv))
......
...@@ -337,7 +337,8 @@ def test_restructure(): ...@@ -337,7 +337,8 @@ def test_restructure():
# ø -> T/B # ø -> T/B
z = Z0() z = Z0()
R(z, 'T/B') R(z, 'T/B')
assert crack_btree(z) == (BTREE_NORMAL, [], LOBucket()) # XXX -> BTREE_ONE #assert crack_btree(z) == (BTREE_NORMAL, [], LOBucket()) # XXX -> BTREE_ONE
assert crack_btree(z) == (BTREE_EMPTY, [], []) # XXX -> BTREE_ONE ?
# ø -> T/T/B # ø -> T/T/B
z = Z0() z = Z0()
...@@ -347,15 +348,25 @@ def test_restructure(): ...@@ -347,15 +348,25 @@ def test_restructure():
assert len(kids) == 0 assert len(kids) == 0
assert isinstance(kids[0], XLOTree) assert isinstance(kids[0], XLOTree)
kind, keys, kids = crack_btree(kids[0]) kind, keys, kids = crack_btree(kids[0])
"""
assert kind, keys == (BTREE_NORMAL, []) # XXX or should it be BTREE_ONE here? assert kind, keys == (BTREE_NORMAL, []) # XXX or should it be BTREE_ONE here?
# XXX no: we need to wire bucket->next properly # XXX no: we need to wire bucket->next properly
assert len(kids) == 0 assert len(kids) == 0
assert isinstance(kids[0], LOBucket) assert isinstance(kids[0], LOBucket)
assert kids[0].keys() == [] assert kids[0].keys() == []
"""
assert kind == BTREE_EMPTY
# XXX ø -> T/T-B/B # ø -> T/T-B/B
# XXX ø -> T/B-T/B z = Z0()
# XXX ø -> T/T-T/B-B R(z, 'T1/T-B/B')
kind, keys, kids = crack_btree(z)
assert kind, keys == (BTREE_NORMAL, 0)
assert len(kids) == 1
# ø -> T/T-T/B-B
z = Z0()
R(z, 'T0/T-T/B-B')
# tree with one not-yet committed bucket # tree with one not-yet committed bucket
...@@ -373,6 +384,31 @@ def test_restructure(): ...@@ -373,6 +384,31 @@ def test_restructure():
# pass # pass
def test_walkBFS():
T = xbtree.Tree
B = xbtree.Bucket
bl = B(); br = B()
tl = T([], bl)
tr = T([], br)
t = T([0], tl, tr)
walkv = list(xbtree._walkBFS(t))
assert len(walkv) == 3 # (t) (tl, tr), (bl, br)
_ = walkv[0]
assert len(_) == 1
assert _[0] is t
_ = walkv[1]
assert len(_) == 2
assert _[0] is tl
assert _[1] is tr
_ = walkv[2]
assert len(_) == 2
assert _[0] is bl
assert _[1] is br
def test_keyvSliceBy(): def test_keyvSliceBy():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment