forked from TrueCloudLab/frostfs-api-go
[#302] pkg/object: Document default values set in NewRange
Document field values of instance constructed via `NewRange`. Assert the values in corresponding unit test. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
4e40f195bc
commit
d443904e43
2 changed files with 21 additions and 1 deletions
|
@ -15,6 +15,10 @@ func NewRangeFromV2(rV2 *object.Range) *Range {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRange creates and initializes blank Range.
|
// NewRange creates and initializes blank Range.
|
||||||
|
//
|
||||||
|
// Defaults:
|
||||||
|
// - offset: 0;
|
||||||
|
// - length: 0.
|
||||||
func NewRange() *Range {
|
func NewRange() *Range {
|
||||||
return NewRangeFromV2(new(object.Range))
|
return NewRangeFromV2(new(object.Range))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package object
|
package object
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,3 +40,19 @@ func TestRange_ToV2(t *testing.T) {
|
||||||
require.Nil(t, x.ToV2())
|
require.Nil(t, x.ToV2())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNewRange(t *testing.T) {
|
||||||
|
t.Run("default values", func(t *testing.T) {
|
||||||
|
r := NewRange()
|
||||||
|
|
||||||
|
// check initial values
|
||||||
|
require.Zero(t, r.GetLength())
|
||||||
|
require.Zero(t, r.GetOffset())
|
||||||
|
|
||||||
|
// convert to v2 message
|
||||||
|
rV2 := r.ToV2()
|
||||||
|
|
||||||
|
require.Zero(t, rV2.GetLength())
|
||||||
|
require.Zero(t, rV2.GetOffset())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue