strconv: fix %.1f, 0.09

Fixes #822.
Credit to https://golang.org/cl/1442041 by danielfleischman

R=rsc
CC=golang-dev
https://golang.org/cl/1738047
This commit is contained in:
Rob Pike 2010-06-29 16:51:56 -07:00
parent 21f8ae8fec
commit 64b6a789a1
3 changed files with 21 additions and 6 deletions

View file

@ -108,6 +108,16 @@ var ftoatests = []ftoaTest{
ftoaTest{-math.Inf(0), 'g', -1, "-Inf"},
ftoaTest{-1, 'b', -1, "-4503599627370496p-52"},
// fixed bugs
ftoaTest{0.9, 'f', 1, "0.9"},
ftoaTest{0.09, 'f', 1, "0.1"},
ftoaTest{0.0999, 'f', 1, "0.1"},
ftoaTest{0.05, 'f', 1, "0.1"},
ftoaTest{0.05, 'f', 0, "0"},
ftoaTest{0.5, 'f', 1, "0.5"},
ftoaTest{0.5, 'f', 0, "0"},
ftoaTest{1.5, 'f', 0, "2"},
}
func TestFtoa(t *testing.T) {