From e0ac55c52637f859c225ac07ef3c9120ee7b1c1b Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 8 Jun 2021 11:04:35 +0300 Subject: [PATCH] [#293] pkg/accounting: Implement and use generator of Decimal Signed-off-by: Leonard Lyubich --- pkg/accounting/decimal_test.go | 5 ++--- pkg/accounting/test/decimal.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 pkg/accounting/test/decimal.go diff --git a/pkg/accounting/decimal_test.go b/pkg/accounting/decimal_test.go index ecab5bb..7591097 100644 --- a/pkg/accounting/decimal_test.go +++ b/pkg/accounting/decimal_test.go @@ -4,6 +4,7 @@ import ( "testing" "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" ) @@ -26,9 +27,7 @@ func TestDecimal_Precision(t *testing.T) { } func TestDecimalEncoding(t *testing.T) { - d := accounting.NewDecimal() - d.SetValue(1) - d.SetPrecision(2) + d := accountingtest.Generate() t.Run("binary", func(t *testing.T) { data, err := d.Marshal() diff --git a/pkg/accounting/test/decimal.go b/pkg/accounting/test/decimal.go new file mode 100644 index 0000000..80014d8 --- /dev/null +++ b/pkg/accounting/test/decimal.go @@ -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 +}