frostfs-sdk-go/accounting/decimal_test.go
Leonard Lyubich 48150852f3 [#170] accounting: Refactor and document package functionality
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2022-03-21 12:37:53 +03:00

46 lines
897 B
Go

package accounting_test
import (
"testing"
v2accounting "github.com/nspcc-dev/neofs-api-go/v2/accounting"
"github.com/nspcc-dev/neofs-sdk-go/accounting"
"github.com/stretchr/testify/require"
)
func TestDecimalData(t *testing.T) {
const v, p = 4, 2
var d accounting.Decimal
require.Zero(t, d.Value())
require.Zero(t, d.Precision())
d.SetValue(v)
d.SetPrecision(p)
require.EqualValues(t, v, d.Value())
require.EqualValues(t, p, d.Precision())
}
func TestDecimalMessageV2(t *testing.T) {
var (
d accounting.Decimal
m v2accounting.Decimal
)
m.SetValue(7)
m.SetPrecision(8)
d.ReadFromMessageV2(m)
require.EqualValues(t, m.GetValue(), d.Value())
require.EqualValues(t, m.GetPrecision(), d.Precision())
var m2 v2accounting.Decimal
d.WriteToMessageV2(&m2)
require.EqualValues(t, d.Value(), m2.GetValue())
require.EqualValues(t, d.Precision(), m2.GetPrecision())
}