Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
513ef608
Commit
513ef608
authored
Oct 04, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d4da2a21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
go/zodb/btree/btree_test.go
go/zodb/btree/btree_test.go
+48
-2
go/zodb/btree/testdata/gen-testdata
go/zodb/btree/testdata/gen-testdata
+0
-1
No files found.
go/zodb/btree/btree_test.go
View file @
513ef608
...
...
@@ -23,6 +23,7 @@ package btree
import
(
"context"
"reflect"
"testing"
"lab.nexedi.com/kirr/go123/exc"
...
...
@@ -98,6 +99,12 @@ func (b *bucketWrap) MaxKey(ctx context.Context) (k int64, ok bool, err error) {
return
}
// tVisit is information about one visit call.
type
tVisit
struct
{
node
zodb
.
Oid
keycov
LKeyRange
}
func
TestBTree
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
ctx
:=
context
.
Background
()
...
...
@@ -105,6 +112,10 @@ func TestBTree(t *testing.T) {
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
func
()
{
err
:=
stor
.
Close
();
X
(
err
)
}()
db
:=
zodb
.
NewDB
(
stor
,
&
zodb
.
DBOptions
{})
defer
func
()
{
err
:=
db
.
Close
();
X
(
err
)
...
...
@@ -118,8 +129,6 @@ func TestBTree(t *testing.T) {
t
.
Fatal
(
err
)
}
// XXX close db/stor
// go through small test Buckets/BTrees and verify that Get(key) is as expected.
for
_
,
tt
:=
range
smallTestv
{
xobj
,
err
:=
conn
.
Get
(
ctx
,
tt
.
oid
)
...
...
@@ -262,4 +271,41 @@ func TestBTree(t *testing.T) {
// XXX verify FirstBucket / Next ?
verifyFirstBucket
(
B3
)
// verify nodes/keycov visited through VGet/V{Min,Max}Key
xBv
,
err
:=
conn
.
Get
(
ctx
,
Bv_oid
);
X
(
err
)
Bv
,
ok
:=
xBv
.
(
*
LOBTree
)
if
!
ok
{
t
.
Fatalf
(
"Bv: %v; got %T; want LOBTree"
,
Bv_oid
,
xBv
)
}
for
k
,
visitOK
:=
range
Bvdict
{
visit
:=
[]
tVisit
{}
_
,
_
,
err
:=
Bv
.
VGet
(
ctx
,
k
,
func
(
node
LONode
,
keycov
LKeyRange
)
{
visit
=
append
(
visit
,
tVisit
{
node
.
POid
(),
keycov
})
});
X
(
err
)
if
!
reflect
.
DeepEqual
(
visit
,
visitOK
)
{
t
.
Errorf
(
"VGet(%d): visit:
\n
have: %v
\n
want: %v"
,
k
,
visit
,
visitOK
)
}
}
/* XXX reenable
visitMinOK := Bvdict[kmin]
visitMaxOK := Bvdict[kmax]
visitMin := []tVisit{}
visitMax := []tVisit{}
_, _, err = Bv.VMinKey(ctx, func(node LONode, keycov LKeyRange) {
visitMin = append(visitMin, tVisit{node.POid(), keycov})
}); X(err)
_, _, err = Bv.VMaxKey(ctx, func(node LONode, keycov LKeyRange) {
visitMax = append(visitMax, tVisit{node.POid(), keycov})
}); X(err)
if !reflect.DeepEqual(visitMin, visitMinOK) {
t.Errorf("VMinKey(): visit:\nhave: %v\nwant: %v", visitMin, visitMinOK)
}
if !reflect.DeepEqual(visitMax, visitMaxOK) {
t.Errorf("VMaxKey(): visit:\nhave: %v\nwant: %v", visitMax, visitMaxOK)
}
*/
}
go/zodb/btree/testdata/gen-testdata
View file @
513ef608
...
...
@@ -59,7 +59,6 @@ def main2():
print
>>
f
,
v
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"package btree
\
n
"
)
#emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
def
emititems
(
b
):
s
=
"testEntry{oid: %s, kind: %s, itemv: []kv{"
\
...
...
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