tempo/pkg/tempopb/prealloc_test.go
Zach Leslie a5a7adb5cd Run gofumpt -w on all go files and integrate with CI (#2584)
* Include gofumpt and goimports in tools

* Replace gofmt with gofumpt in Makefile

* Run `make fmt`

* Adhere to goconst lint rule

* Include gofumpt note in the CONTRIBUTING.md

* Update CHANGELOG
2023-07-20 16:02:05 +00:00

43 lines
858 B
Go

package tempopb
import (
crand "crypto/rand"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestUnmarshal(t *testing.T) {
dummyData := make([]byte, 10)
_, err := crand.Read(dummyData)
require.NoError(t, err)
preallocReq := &PreallocBytes{}
err = preallocReq.Unmarshal(dummyData)
assert.NoError(t, err)
assert.Equal(t, dummyData, preallocReq.Slice)
}
func TestMarshal(t *testing.T) {
preallocReq := &PreallocBytes{
Slice: make([]byte, 10),
}
_, err := crand.Read(preallocReq.Slice)
require.NoError(t, err)
dummyData := make([]byte, 10)
_, err = preallocReq.MarshalTo(dummyData)
assert.NoError(t, err)
assert.Equal(t, preallocReq.Slice, dummyData)
}
func TestSize(t *testing.T) {
preallocReq := &PreallocBytes{
Slice: make([]byte, 10),
}
assert.Equal(t, 10, preallocReq.Size())
}