[#49] message/test: Add test for zero-alloc StableSize()
All checks were successful
All checks were successful
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
43ad0f114c
commit
7133a01ccf
1 changed files with 6 additions and 0 deletions
|
@ -17,6 +17,7 @@ type jsonMessage interface {
|
|||
|
||||
type binaryMessage interface {
|
||||
StableMarshal([]byte) []byte
|
||||
StableSize() int
|
||||
Unmarshal([]byte) error
|
||||
}
|
||||
|
||||
|
@ -53,6 +54,11 @@ func TestRPCMessage(t *testing.T, msgGens ...func(empty bool) message.Message) {
|
|||
}
|
||||
|
||||
if bm, ok := msg.(binaryMessage); ok {
|
||||
t.Run(fmt.Sprintf("%T.StableSize() does no allocations", bm), func(t *testing.T) {
|
||||
require.Zero(t, testing.AllocsPerRun(1000, func() {
|
||||
_ = bm.StableSize()
|
||||
}))
|
||||
})
|
||||
t.Run(fmt.Sprintf("Binary_%T", msg), func(t *testing.T) {
|
||||
data := bm.StableMarshal(nil)
|
||||
|
||||
|
|
Loading…
Reference in a new issue