[#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

@ -8,6 +8,8 @@ import (
type Range object.Range
// NewRangeFromV2 wraps v2 Range message to Range.
//
// Nil object.Range converts to nil.
func NewRangeFromV2(rV2 *object.Range) *Range {
return (*Range)(rV2)
}
@ -18,6 +20,8 @@ func NewRange() *Range {
}
// ToV2 converts Range to v2 Range message.
//
// Nil Range converts to nil.
func (r *Range) ToV2() *object.Range {
return (*object.Range)(r)
}