forked from TrueCloudLab/frostfs-api-go
[#293] pkg/accounting: Implement and use generator of Decimal
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0f478a9dc6
commit
e0ac55c526
2 changed files with 16 additions and 3 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/accounting"
|
"github.com/nspcc-dev/neofs-api-go/pkg/accounting"
|
||||||
|
accountingtest "github.com/nspcc-dev/neofs-api-go/pkg/accounting/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,9 +27,7 @@ func TestDecimal_Precision(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecimalEncoding(t *testing.T) {
|
func TestDecimalEncoding(t *testing.T) {
|
||||||
d := accounting.NewDecimal()
|
d := accountingtest.Generate()
|
||||||
d.SetValue(1)
|
|
||||||
d.SetPrecision(2)
|
|
||||||
|
|
||||||
t.Run("binary", func(t *testing.T) {
|
t.Run("binary", func(t *testing.T) {
|
||||||
data, err := d.Marshal()
|
data, err := d.Marshal()
|
||||||
|
|
14
pkg/accounting/test/decimal.go
Normal file
14
pkg/accounting/test/decimal.go
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package accountingtest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/accounting"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Generate returns random accounting.Decimal.
|
||||||
|
func Generate() *accounting.Decimal {
|
||||||
|
d := accounting.NewDecimal()
|
||||||
|
d.SetValue(1)
|
||||||
|
d.SetPrecision(2)
|
||||||
|
|
||||||
|
return d
|
||||||
|
}
|
Loading…
Reference in a new issue