forked from TrueCloudLab/frostfs-sdk-go
46 lines
949 B
Go
46 lines
949 B
Go
package accounting_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
v2accounting "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting/grpc"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestDecimalData(t *testing.T) {
|
|
const v, p = 4, 2
|
|
|
|
d := new(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 TestDecimalMessageProtobuf(t *testing.T) {
|
|
var (
|
|
d = new(accounting.Decimal)
|
|
m = new(v2accounting.Decimal)
|
|
)
|
|
|
|
m.SetValue(7)
|
|
m.SetPrecision(8)
|
|
|
|
d.ReadFromProtobuf(m)
|
|
|
|
require.EqualValues(t, m.GetValue(), d.Value())
|
|
require.EqualValues(t, m.GetPrecision(), d.Precision())
|
|
|
|
m2 := new(v2accounting.Decimal)
|
|
|
|
d.WriteToProtobuf(m2)
|
|
|
|
require.EqualValues(t, d.Value(), m2.GetValue())
|
|
require.EqualValues(t, d.Precision(), m2.GetPrecision())
|
|
}
|