Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
afb41a07
Commit
afb41a07
authored
May 11, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
55032df4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
5 deletions
+41
-5
wcfs/internal/xbtree.py
wcfs/internal/xbtree.py
+1
-1
wcfs/internal/xbtree_test.py
wcfs/internal/xbtree_test.py
+40
-4
No files found.
wcfs/internal/xbtree.py
View file @
afb41a07
...
@@ -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
))
...
...
wcfs/internal/xbtree_test.py
View file @
afb41a07
...
@@ -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
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment