diff --git a/pkg/netmap/policy.go b/pkg/netmap/policy.go index ce8a978f..27035536 100644 --- a/pkg/netmap/policy.go +++ b/pkg/netmap/policy.go @@ -13,11 +13,15 @@ func NewPlacementPolicy() *PlacementPolicy { } // NewPlacementPolicyFromV2 converts v2 PlacementPolicy to PlacementPolicy. +// +// Nil netmap.PlacementPolicy converts to nil. func NewPlacementPolicyFromV2(f *netmap.PlacementPolicy) *PlacementPolicy { return (*PlacementPolicy)(f) } // ToV2 converts PlacementPolicy to v2 PlacementPolicy. +// +// Nil PlacementPolicy converts to nil. func (p *PlacementPolicy) ToV2() *netmap.PlacementPolicy { return (*netmap.PlacementPolicy)(p) } diff --git a/pkg/netmap/policy_test.go b/pkg/netmap/policy_test.go index 9fca579a..173317ab 100644 --- a/pkg/netmap/policy_test.go +++ b/pkg/netmap/policy_test.go @@ -144,3 +144,19 @@ func TestPlacementPolicyEncoding(t *testing.T) { require.Equal(t, p, p2) }) } + +func TestNewPlacementPolicy(t *testing.T) { + t.Run("nil", func(t *testing.T) { + var x *PlacementPolicy + + require.Nil(t, x.ToV2()) + }) +} + +func TestNewPlacementPolicyFromV2(t *testing.T) { + t.Run("from nil", func(t *testing.T) { + var x *netmap.PlacementPolicy + + require.Nil(t, NewPlacementPolicyFromV2(x)) + }) +}