mirror of
https://github.com/grafana/tempo.git
synced 2025-03-14 03:06:42 +00:00
* 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
43 lines
858 B
Go
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())
|
|
}
|