[#302] pkg/netmap: Convert nil Selector to nil message

Document that `Selector.ToV2` method return `nil`
when called on `nil`. Document that `NewSelectorFromV2`
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 18:33:38 +03:00 committed by Alex Vanin
parent af1742b48a
commit c47d1fb26b
2 changed files with 29 additions and 13 deletions

View file

@ -161,11 +161,15 @@ func NewSelector() *Selector {
}
// NewSelectorFromV2 converts v2 Selector to Selector.
//
// Nil netmap.Selector converts to nil.
func NewSelectorFromV2(f *netmap.Selector) *Selector {
return (*Selector)(f)
}
// ToV2 converts Selector to v2 Selector.
//
// Nil Selector converts to nil.
func (s *Selector) ToV2() *netmap.Selector {
return (*netmap.Selector)(s)
}