forked from TrueCloudLab/frostfs-api-go
[#293] pkg/accounting: Implement and use generator of Decimal
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>support/v2.15
parent
0f478a9dc6
commit
e0ac55c526
|
@ -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()
|
||||
|
|
|
@ -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 New Issue