mirror of
https://github.com/waku-org/go-multiaddr.git
synced 2025-02-23 03:28:12 +00:00
24 lines
426 B
Go
24 lines
426 B
Go
package multiaddr
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"testing"
|
|
)
|
|
|
|
func checkVarint(t *testing.T, x int) {
|
|
buf := make([]byte, binary.MaxVarintLen64)
|
|
expected := binary.PutUvarint(buf, uint64(x))
|
|
|
|
size := VarintSize(x)
|
|
if size != expected {
|
|
t.Fatalf("expected varintsize of %d to be %d, got %d", x, expected, size)
|
|
}
|
|
}
|
|
|
|
func TestVarintSize(t *testing.T) {
|
|
max := 1 << 16
|
|
for x := 0; x < max; x++ {
|
|
checkVarint(t, x)
|
|
}
|
|
}
|