Migrate package imports from next.orly.dev to new orly domain structure; add new varint and binary encoders with comprehensive tests; enhance existing tag and envelope implementations with additional methods, validations, and test coverage; introduce shared test.sh script for streamlined testing across modules.
This commit is contained in:
28
pkg/encoders/varint/varint_test.go
Normal file
28
pkg/encoders/varint/varint_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package varint
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"lol.mleku.dev/chk"
|
||||
"lukechampine.com/frand"
|
||||
)
|
||||
|
||||
func TestEncode_Decode(t *testing.T) {
|
||||
var v uint64
|
||||
for range 10000000 {
|
||||
v = uint64(frand.Intn(math.MaxInt64))
|
||||
buf1 := new(bytes.Buffer)
|
||||
Encode(buf1, v)
|
||||
buf2 := bytes.NewBuffer(buf1.Bytes())
|
||||
u, err := Decode(buf2)
|
||||
if chk.E(err) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if u != v {
|
||||
t.Fatalf("expected %d got %d", v, u)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user