diff --git a/pkg/netmap/filter.go b/pkg/netmap/filter.go index bc281e63..de6c9399 100644 --- a/pkg/netmap/filter.go +++ b/pkg/netmap/filter.go @@ -153,11 +153,15 @@ func NewFilter() *Filter { } // NewFilterFromV2 converts v2 Filter to Filter. +// +// Nil netmap.Filter converts to nil. func NewFilterFromV2(f *netmap.Filter) *Filter { return (*Filter)(f) } // ToV2 converts Filter to v2 Filter. +// +// Nil Filter converts to nil. func (f *Filter) ToV2() *netmap.Filter { return (*netmap.Filter)(f) } diff --git a/pkg/netmap/filter_test.go b/pkg/netmap/filter_test.go index 4778432a..a9eadaa8 100644 --- a/pkg/netmap/filter_test.go +++ b/pkg/netmap/filter_test.go @@ -213,6 +213,18 @@ func testFilter() *Filter { } func TestFilterFromV2(t *testing.T) { + t.Run("nil from V2", func(t *testing.T) { + var x *netmap.Filter + + require.Nil(t, NewFilterFromV2(x)) + }) + + t.Run("nil to V2", func(t *testing.T) { + var x *Filter + + require.Nil(t, x.ToV2()) + }) + fV2 := new(netmap.Filter) fV2.SetOp(netmap.GE) fV2.SetName("name")