From 2d5dcfb3f6cb7d49fcdf52962ed049f1e69dabd9 Mon Sep 17 00:00:00 2001 From: Ahmet Alp Balkan Date: Fri, 22 Jun 2018 11:43:41 -0700 Subject: [PATCH] currencyservice: fix test, add test for fractional result Signed-off-by: Ahmet Alp Balkan --- src/currencyservicetemp/money_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/currencyservicetemp/money_test.go b/src/currencyservicetemp/money_test.go index fa2a913..fcf630a 100644 --- a/src/currencyservicetemp/money_test.go +++ b/src/currencyservicetemp/money_test.go @@ -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}, },