Commit 8bccfd9a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a082acd6
......@@ -287,11 +287,56 @@ def test_restructure():
N = 8 # maxkey
zblkv = [] # zblk[i] = ZBlk corresponding to block #i
X = [] # X[i] = XBlk corresponding to block #i
for i in range(N):
zblkv.append(XBlk('abcdefgh'[i]))
IOSet
# prepare ztree with given keys via usual way
def Z(*keys):
ztree = IOTree() # XXX -> class with node size=2
for k in keys:
ztree[k] = zblkv[k]
return ztree
# R restructures ztree according to new topology.
def R(ztree, newtopo):
newStructure = xbtree.TopoDecode(newtopo)
xbtree.Restructure(ztree, newStructure)
# Z0 creates new empty tree
def Z0():
z = Z()
assert bcheck.crack_btree() == BTREE_EMPTY, [], []
return z
z = Z0()
R(z, 'T/B')
assert bcheck.crack_btree(z) == BTREE_NORMAL, [], IOBucket()
z = Z0()
R(z, 'T/T/B')
kind, keys, kids = bcheck.crack_btree(z)
assert kind, keys == BTREE_NORMAL, []
assert len(kids) == 0
assert isinstance(kids[0], IOTree)
kind, keys, kids = bcheck.crack_btree(kids[0])
assert kind, keys == BTREE_NORMAL, [] # XXX or should it be BTREE_ONE here?
assert len(kids) == 0
assert isinstance(kids[0], IOBucket)
assert kids[0].keys() == []
# tree with one not-yet committed bucket
z = Z(1, 3)
assert bcheck.crack_btree() == BTREE_ONE, (1, X[1], 3, X[3]), None
# XXX tree with one committed bucket
# XXX tree with 2 buckets
#for nkeys in range(5):
# pass
......
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