[#302] pkg/object: Convert nil Range to nil message

Document that `Range.ToV2` method return `nil`
when called on `nil`. Document that `NewRangeFromV2`
function return `nil` when called on `nil`. Write
corresponding unit tests.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-06-08 19:06:43 +03:00 committed by Alex Vanin
parent 6c12b4dfb6
commit 4e40f195bc
2 changed files with 21 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package object
import (
"github.com/nspcc-dev/neofs-api-go/v2/object"
"testing"
"github.com/stretchr/testify/require"
@ -23,3 +24,19 @@ func TestRange_SetLength(t *testing.T) {
require.Equal(t, ln, r.GetLength())
}
func TestNewRangeFromV2(t *testing.T) {
t.Run("from nil", func(t *testing.T) {
var x *object.Range
require.Nil(t, NewRangeFromV2(x))
})
}
func TestRange_ToV2(t *testing.T) {
t.Run("nil", func(t *testing.T) {
var x *Range
require.Nil(t, x.ToV2())
})
}