currencyservice: fix test, add test for fractional result

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-06-22 11:43:41 -07:00
parent 3ae9448346
commit 2d5dcfb3f6

View file

@ -15,7 +15,7 @@ func Test_convert(t *testing.T) {
tests := []struct {
name string
args args
want *pb.MoneyAmount
want pb.MoneyAmount
}{
{
"0.33*3", args{pb.MoneyAmount{Decimal: 0, Fractional: 330}, 3}, pb.MoneyAmount{Decimal: 0, Fractional: 99},
@ -26,6 +26,9 @@ func Test_convert(t *testing.T) {
{
"10.00*1.5", args{pb.MoneyAmount{Decimal: 10}, 1.5}, pb.MoneyAmount{Decimal: 15},
},
{
"10.00*1/3", args{pb.MoneyAmount{Decimal: 10}, 1.0 / 3}, pb.MoneyAmount{Decimal: 3, Fractional: 3},
},
{
"32.320*0.5 (trailing zero removed)", args{pb.MoneyAmount{Decimal: 32, Fractional: 32}, 0.5}, pb.MoneyAmount{Decimal: 16, Fractional: 16},
},