Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-cid
Commits
46aac888
Commit
46aac888
authored
Oct 13, 2020
by
Rod Vagg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverage: more tests for varint
parent
f60e346b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
varint_test.go
varint_test.go
+26
-0
No files found.
varint_test.go
View file @
46aac888
...
@@ -28,3 +28,29 @@ func TestUvarintRoundTrip(t *testing.T) {
...
@@ -28,3 +28,29 @@ func TestUvarintRoundTrip(t *testing.T) {
}
}
}
}
}
}
func
TestUvarintEdges
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
input
[]
byte
want
error
}{
{
"ErrNotMinimal"
,
[]
byte
{
0x01
|
0x80
,
0
},
varint
.
ErrNotMinimal
},
{
"ErrOverflow"
,
[]
byte
{
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x80
,
0x01
},
varint
.
ErrOverflow
},
{
"ErrUnderflow"
,
[]
byte
{
0x80
},
varint
.
ErrUnderflow
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
name
,
func
(
t
*
testing
.
T
)
{
v
,
l1
,
err
:=
uvarint
(
string
(
test
.
input
))
if
err
!=
test
.
want
{
t
.
Fatalf
(
"error case (%v) should return varint.%s (got: %v)"
,
test
.
input
,
test
.
name
,
err
)
}
if
v
!=
0
{
t
.
Fatalf
(
"error case (%v) should return 0 value (got %d)"
,
test
.
input
,
v
)
}
if
l1
!=
0
{
t
.
Fatalf
(
"error case (%v) should return 0 length (got %d)"
,
test
.
input
,
l1
)
}
})
}
}
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