[#293] pkg/accounting: Implement and use generator of Decimal

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-06-08 11:04:35 +03:00 committed by Alex Vanin
parent 0f478a9dc6
commit e0ac55c526
2 changed files with 16 additions and 3 deletions

View file

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

View 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
}