2021-07-06 16:34:02 +00:00
|
|
|
package stackitem
|
|
|
|
|
|
|
|
import (
|
2021-07-06 21:18:00 +00:00
|
|
|
"errors"
|
2021-07-06 16:34:02 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSerializationMaxErr(t *testing.T) {
|
|
|
|
base := make([]byte, MaxSize/2+1)
|
|
|
|
item := Make(base)
|
|
|
|
|
2021-07-06 21:18:00 +00:00
|
|
|
// Pointer is unserializable, but we specifically want to catch ErrTooBig.
|
|
|
|
arr := []Item{item, item.Dup(), NewPointer(0, []byte{})}
|
2021-07-06 16:34:02 +00:00
|
|
|
aitem := Make(arr)
|
|
|
|
|
2021-07-06 16:56:23 +00:00
|
|
|
_, err := Serialize(item)
|
2021-07-06 16:34:02 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-07-06 16:56:23 +00:00
|
|
|
_, err = Serialize(aitem)
|
2021-07-06 21:18:00 +00:00
|
|
|
require.True(t, errors.Is(err, ErrTooBig), err)
|
2021-07-06 16:34:02 +00:00
|
|
|
}
|