Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
b
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
b
Commits
71e50bd9
Commit
71e50bd9
authored
Oct 23, 2013
by
Jan Mercl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More test coverage
parent
4b2c36df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
167 additions
and
0 deletions
+167
-0
all_test.go
all_test.go
+167
-0
No files found.
all_test.go
View file @
71e50bd9
...
...
@@ -6,6 +6,7 @@ package b
import
(
"fmt"
"io"
"math"
"path"
"runtime"
...
...
@@ -764,3 +765,169 @@ func BenchmarkPrev1e3(b *testing.B) {
}
}
}
func
TestSeekFirst0
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
_
,
err
:=
b
.
SeekFirst
()
if
g
,
e
:=
err
,
io
.
EOF
;
g
!=
e
{
t
.
Fatal
(
g
,
e
)
}
}
func
TestSeekFirst1
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
1
,
10
)
en
,
err
:=
b
.
SeekFirst
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Next
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
func
TestSeekFirst2
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
1
,
10
)
b
.
Set
(
2
,
20
)
en
,
err
:=
b
.
SeekFirst
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Next
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
k
!=
2
||
v
!=
20
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
func
TestSeekFirst3
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
2
,
20
)
b
.
Set
(
3
,
30
)
b
.
Set
(
1
,
10
)
en
,
err
:=
b
.
SeekFirst
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Next
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
k
!=
2
||
v
!=
20
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
k
!=
3
||
v
!=
30
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Next
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
func
TestSeekLast0
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
_
,
err
:=
b
.
SeekLast
()
if
g
,
e
:=
err
,
io
.
EOF
;
g
!=
e
{
t
.
Fatal
(
g
,
e
)
}
}
func
TestSeekLast1
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
1
,
10
)
en
,
err
:=
b
.
SeekLast
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Prev
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
func
TestSeekLast2
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
1
,
10
)
b
.
Set
(
2
,
20
)
en
,
err
:=
b
.
SeekLast
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Prev
()
if
k
!=
2
||
v
!=
20
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
func
TestSeekLast3
(
t
*
testing
.
T
)
{
b
:=
TreeNew
(
cmp
)
b
.
Set
(
2
,
20
)
b
.
Set
(
3
,
30
)
b
.
Set
(
1
,
10
)
en
,
err
:=
b
.
SeekLast
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
k
,
v
,
err
:=
en
.
Prev
()
if
k
!=
3
||
v
!=
30
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
k
!=
2
||
v
!=
20
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
k
!=
1
||
v
!=
10
||
err
!=
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
k
,
v
,
err
=
en
.
Prev
()
if
err
==
nil
{
t
.
Fatal
(
k
,
v
,
err
)
}
}
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