[#302] pkg/version: Convert nil Version to nil message

Document that `Version.ToV2` method return `nil`
when called on `nil`. Document that `NewVersionFromV2`
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 21:22:33 +03:00 committed by Alex Vanin
parent bb0cd8e4c0
commit 768adfdd15
2 changed files with 22 additions and 1 deletions

View file

@ -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)
}