This repository has been archived on 2019-06-23. You can view files and clone it, but cannot push or open issues/pull-requests.
mumbledj/vendor/github.com/layeh/gumble/gumble/varint/varint_test.go

33 lines
508 B
Go

package varint
import "testing"
func TestRange(t *testing.T) {
fn := func(i int64) {
var b [MaxVarintLen]byte
size := Encode(b[:], i)
if size == 0 {
t.Errorf("Encode returned size 0\n")
}
s := b[:size]
val, size := Decode(s)
if size == 0 {
t.Errorf("Decode return size 0\n")
}
if i != val {
t.Errorf("Encoded %d (%v) equals decoded %d\n", i, s, val)
}
}
for i := int64(-10000); i <= 10000; i++ {
fn(i)
}
fn(134342525)
fn(10282934828342)
fn(1028293482834200000)
}