diff --git a/pkg/version.go b/pkg/version.go index 7e2e645d..68fd8e77 100644 --- a/pkg/version.go +++ b/pkg/version.go @@ -12,6 +12,8 @@ type Version refs.Version const sdkMjr, sdkMnr = 2, 6 // NewVersionFromV2 wraps v2 Version message to Version. +// +// Nil refs.Version converts to nil. func NewVersionFromV2(v *refs.Version) *Version { return (*Version)(v) } @@ -58,6 +60,8 @@ func (v *Version) SetMinor(val uint32) { } // ToV2 converts Version to v2 Version message. +// +// Nil Version converts to nil. func (v *Version) ToV2() *refs.Version { return (*refs.Version)(v) } diff --git a/pkg/version_test.go b/pkg/version_test.go index 2f5ee282..fa756554 100644 --- a/pkg/version_test.go +++ b/pkg/version_test.go @@ -3,10 +3,11 @@ package pkg import ( "testing" + "github.com/nspcc-dev/neofs-api-go/v2/refs" "github.com/stretchr/testify/require" ) -func TestNewVersionFromV2(t *testing.T) { +func TestNewVersion(t *testing.T) { v := NewVersion() var mjr, mnr uint32 = 1, 2 @@ -88,3 +89,19 @@ func TestVersionEncoding(t *testing.T) { require.Equal(t, v, v2) }) } + +func TestNewVersionFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *refs.Version + + require.Nil(t, NewVersionFromV2(x)) + }) +} + +func TestVersion_ToV2(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *Version + + require.Nil(t, x.ToV2()) + }) +}