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
ed2de0de
Commit
ed2de0de
authored
Sep 29, 2021
by
Kirill Smelkov
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X Tests for Get
parent
7ae1abd4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
16 deletions
+64
-16
wcfs/internal/xbtree/blib/rangemap_test.go
wcfs/internal/xbtree/blib/rangemap_test.go
+54
-6
wcfs/internal/xbtree/blib/rangeset_test.go
wcfs/internal/xbtree/blib/rangeset_test.go
+10
-10
No files found.
wcfs/internal/xbtree/blib/rangemap_test.go
View file @
ed2de0de
...
@@ -36,7 +36,6 @@ func TestRangedMap(t *testing.T) {
...
@@ -36,7 +36,6 @@ func TestRangedMap(t *testing.T) {
Set
*
RangedMap
// A.SetRange(B.keycov, B.value)
Set
*
RangedMap
// A.SetRange(B.keycov, B.value)
Del
*
RangedMap
// A.DelRange(B.keycov)
Del
*
RangedMap
// A.DelRange(B.keycov)
Has
bool
// A.HasRange(B.keycov)
Has
bool
// A.HasRange(B.keycov)
// XXX Get?
}
}
E
:=
func
(
A
*
RangedMap
,
B
RangedMapEntry
,
S
,
D
*
RangedMap
,
H
bool
)
testEntry
{
E
:=
func
(
A
*
RangedMap
,
B
RangedMapEntry
,
S
,
D
*
RangedMap
,
H
bool
)
testEntry
{
return
testEntry
{
A
,
B
,
S
,
D
,
H
}
return
testEntry
{
A
,
B
,
S
,
D
,
H
}
...
@@ -142,16 +141,12 @@ func TestRangedMap(t *testing.T) {
...
@@ -142,16 +141,12 @@ func TestRangedMap(t *testing.T) {
r
:=
B
.
KeyRange
r
:=
B
.
KeyRange
v
:=
B
.
Value
v
:=
B
.
Value
has
:=
A
.
HasRange
(
r
)
assertMHasRange
(
t
,
A
,
r
,
tt
.
Has
)
Aset
:=
A
.
Clone
()
Aset
:=
A
.
Clone
()
Adel
:=
A
.
Clone
()
Adel
:=
A
.
Clone
()
Aset
.
SetRange
(
r
,
v
)
Aset
.
SetRange
(
r
,
v
)
Adel
.
DelRange
(
r
)
Adel
.
DelRange
(
r
)
if
!
(
has
==
tt
.
Has
)
{
t
.
Errorf
(
"HasRange:
\n
A: %s
\n
r: %s
\n
->·: %t
\n
ok·: %t
\n
"
,
A
,
r
,
has
,
tt
.
Has
)
}
if
!
Aset
.
Equal
(
tt
.
Set
)
{
if
!
Aset
.
Equal
(
tt
.
Set
)
{
t
.
Errorf
(
"SetRange:
\n
A: %s
\n
e: %s
\n
->·: %s
\n
ok·: %s
\n
"
,
A
,
B
,
Aset
,
tt
.
Set
)
t
.
Errorf
(
"SetRange:
\n
A: %s
\n
e: %s
\n
->·: %s
\n
ok·: %s
\n
"
,
A
,
B
,
Aset
,
tt
.
Set
)
...
@@ -162,6 +157,59 @@ func TestRangedMap(t *testing.T) {
...
@@ -162,6 +157,59 @@ func TestRangedMap(t *testing.T) {
}
}
assertMHasRange
(
t
,
Aset
,
r
,
true
)
assertMHasRange
(
t
,
Adel
,
r
,
false
)
verifyGet
(
t
,
A
)
verifyGet
(
t
,
Aset
)
verifyGet
(
t
,
Adel
)
}
}
// assertMHasRange asserts that RangeMap M.HasRange(r) == hasOK.
func
assertMHasRange
(
t
*
testing
.
T
,
M
*
_RangedMap_str
,
r
KeyRange
,
hasOK
bool
)
{
t
.
Helper
()
has
:=
M
.
HasRange
(
r
)
if
!
(
has
==
hasOK
)
{
t
.
Errorf
(
"HasRange:
\n
M: %s
\n
r: %s
\n
->·: %t
\n
ok·: %t
\n
"
,
M
,
r
,
has
,
hasOK
)
}
}
}
// verifyGet verifies RangedMap.Get .
func
verifyGet
(
t
*
testing
.
T
,
M
*
_RangedMap_str
)
{
type
RangedMap
=
_RangedMap_str
type
RangedMapEntry
=
_RangedMap_strEntry
t
.
Helper
()
var
Mranges
[]
RangedMapEntry
Mranges
=
append
(
Mranges
,
M
.
AllRanges
()
...
)
// copy just in case it changes on Get
for
_
,
e
:=
range
Mranges
{
for
k
:=
e
.
Lo
;
k
<=
e
.
Hi_
;
k
++
{
v
,
ok
:=
M
.
Get_
(
k
)
if
!
(
v
==
e
.
Value
&&
ok
)
{
t
.
Errorf
(
"%s
\t
Get(%s):
\n
have: %q, %t
\n
want: %q, true"
,
M
,
KStr
(
k
),
v
,
ok
,
e
.
Value
)
}
}
}
// verify no-data
// NA = [-∞,∞) \ M
na
:=
RangedKeySet
{}
na
.
AddRange
(
KeyRange
{
-
10
,
+
10
})
// models -∞,∞
for
_
,
e
:=
range
Mranges
{
na
.
DelRange
(
e
.
KeyRange
)
}
for
_
,
r
:=
range
na
.
AllRanges
()
{
for
k
:=
r
.
Lo
;
k
<=
r
.
Hi_
;
k
++
{
v
,
ok
:=
M
.
Get_
(
k
)
if
!
(
v
==
""
&&
!
ok
)
{
t
.
Errorf
(
"%s
\t
Get(%s):
\n
have: %q, %t
\n
want: %q, false"
,
M
,
KStr
(
k
),
v
,
ok
,
""
)
}
}
}
}
}
wcfs/internal/xbtree/blib/rangeset_test.go
View file @
ed2de0de
...
@@ -158,22 +158,22 @@ func TestRangedKeySet(t *testing.T) {
...
@@ -158,22 +158,22 @@ func TestRangedKeySet(t *testing.T) {
}
}
// HasRange
// HasRange
assertHasRange
(
t
,
A
.
AllRanges
(),
A
,
true
)
assert
S
HasRange
(
t
,
A
.
AllRanges
(),
A
,
true
)
assertHasRange
(
t
,
B
.
AllRanges
(),
B
,
true
)
assert
S
HasRange
(
t
,
B
.
AllRanges
(),
B
,
true
)
assertHasRange
(
t
,
A
.
AllRanges
(),
U
,
true
)
assert
S
HasRange
(
t
,
A
.
AllRanges
(),
U
,
true
)
assertHasRange
(
t
,
B
.
AllRanges
(),
U
,
true
)
assert
S
HasRange
(
t
,
B
.
AllRanges
(),
U
,
true
)
Dab
:=
D
Dab
:=
D
Dba
:=
B
.
Difference
(
A
)
Dba
:=
B
.
Difference
(
A
)
assertHasRange
(
t
,
Dab
.
AllRanges
(),
A
,
true
)
assert
S
HasRange
(
t
,
Dab
.
AllRanges
(),
A
,
true
)
assertHasRange
(
t
,
Dab
.
AllRanges
(),
B
,
false
)
assert
S
HasRange
(
t
,
Dab
.
AllRanges
(),
B
,
false
)
assertHasRange
(
t
,
Dba
.
AllRanges
(),
B
,
true
)
assert
S
HasRange
(
t
,
Dba
.
AllRanges
(),
B
,
true
)
assertHasRange
(
t
,
Dba
.
AllRanges
(),
A
,
false
)
assert
S
HasRange
(
t
,
Dba
.
AllRanges
(),
A
,
false
)
}
}
}
}
// assert
HasRange asserts for all ranges from rangev that S.HasRange(r) == hasOK
// assert
SHasRange asserts for all ranges from rangev that RangedSet S.HasRange(r) == hasOK.
func
assertHasRange
(
t
*
testing
.
T
,
rangev
[]
KeyRange
,
S
*
RangedKeySet
,
hasOK
bool
)
{
func
assert
S
HasRange
(
t
*
testing
.
T
,
rangev
[]
KeyRange
,
S
*
RangedKeySet
,
hasOK
bool
)
{
t
.
Helper
()
t
.
Helper
()
for
_
,
r
:=
range
rangev
{
for
_
,
r
:=
range
rangev
{
has
:=
S
.
HasRange
(
r
)
has
:=
S
.
HasRange
(
r
)
...
...
Kirill Smelkov
@kirr
mentioned in commit
b7c560c5
·
Oct 27, 2021
mentioned in commit
b7c560c5
mentioned in commit b7c560c5fd08d93518d3d20ec0633fcbdcd1dc16
Toggle commit list
Kirill Smelkov
@kirr
mentioned in commit
1f2cd49d
·
Oct 28, 2021
mentioned in commit
1f2cd49d
mentioned in commit 1f2cd49d230d897a9e006987d0d3a26df4987a31
Toggle commit list
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