diff options
Diffstat (limited to 'vendor/golang.org/x/text/internal/number/decimal_test.go')
-rw-r--r-- | vendor/golang.org/x/text/internal/number/decimal_test.go | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/vendor/golang.org/x/text/internal/number/decimal_test.go b/vendor/golang.org/x/text/internal/number/decimal_test.go index 04aa8b2c8..97c7e25b6 100644 --- a/vendor/golang.org/x/text/internal/number/decimal_test.go +++ b/vendor/golang.org/x/text/internal/number/decimal_test.go @@ -256,12 +256,10 @@ func TestConvert(t *testing.T) { rc RoundingContext out string }{ - // TODO: uncommented tests can be restored when convert does its own - // rounding. - // {-0.001, scale2, "-0.00"}, // not normalized - // {0.1234, prec3, "0.123"}, - // {1234.0, prec3, "1230"}, - // {1.2345e10, prec3, "12300000000"}, + {-0.001, scale2, "-0.00"}, + {0.1234, prec3, "0.123"}, + {1234.0, prec3, "1230"}, + {1.2345e10, prec3, "12300000000"}, {int8(-34), scale2, "-34"}, {int16(-234), scale2, "-234"}, @@ -273,18 +271,37 @@ func TestConvert(t *testing.T) { {uint32(234), scale2, "234"}, {uint64(234), scale2, "234"}, {uint(234), scale2, "234"}, - {-1e9, scale2, "-1000000000"}, - {0.234, scale2away, "0.234"}, // rounding postponed as not ToNearestEven + {-1e9, scale2, "-1000000000.00"}, + // The following two causes this result to have a lot of digits: + // 1) 0.234 cannot be accurately represented as a float64, and + // 2) as strconv does not support the rounding AwayFromZero, Convert + // leaves the rounding to caller. + {0.234, scale2away, + "0.2340000000000000135447209004269097931683063507080078125"}, + {0.0249, inc0_05, "0.00"}, + {0.025, inc0_05, "0.00"}, + {0.0251, inc0_05, "0.05"}, {0.03, inc0_05, "0.05"}, - {0.025, inc0_05, "0"}, - {0.075, inc0_05, "0.1"}, + {0.049, inc0_05, "0.05"}, + {0.05, inc0_05, "0.05"}, + {0.051, inc0_05, "0.05"}, + {0.0749, inc0_05, "0.05"}, + {0.075, inc0_05, "0.10"}, + {0.0751, inc0_05, "0.10"}, + {324, inc50, "300"}, {325, inc50, "300"}, + {326, inc50, "350"}, + {349, inc50, "350"}, + {350, inc50, "350"}, + {351, inc50, "350"}, + {374, inc50, "350"}, {375, inc50, "400"}, + {376, inc50, "400"}, // Here the scale is 2, but the digits get shifted left. As we use // AppendFloat to do the rounding an exta 0 gets added. - {0.123, roundShift, "0.123"}, + {0.123, roundShift, "0.1230"}, {converter(3), scale2, "100"}, |