]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: include ±Inf and NaN in the complex format test
authorRob Pike <r@golang.org>
Wed, 18 Jun 2014 17:57:18 +0000 (10:57 -0700)
committerRob Pike <r@golang.org>
Wed, 18 Jun 2014 17:57:18 +0000 (10:57 -0700)
Just to be more thorough.
No need to push this to 1.3; it's just a test change that
worked without any changes to the code being tested.

LGTM=crawshaw
R=golang-codereviews, crawshaw
CC=golang-codereviews
https://golang.org/cl/109080045

src/pkg/fmt/fmt_test.go

index 430da628aa6a8370b3b1a1ee3746aacde1ba9f91..ef8b2ad86e9b28f97760067cd9555f9fce4675da 100644 (file)
@@ -676,7 +676,7 @@ func TestSprintf(t *testing.T) {
 // thing as if done by hand with two singleton prints.
 func TestComplexFormatting(t *testing.T) {
        var yesNo = []bool{true, false}
-       var signs = []float64{1, 0, -1}
+       var values = []float64{1, 0, -1, math.Inf(1), math.Inf(-1), math.NaN()}
        for _, plus := range yesNo {
                for _, zero := range yesNo {
                        for _, space := range yesNo {
@@ -701,10 +701,10 @@ func TestComplexFormatting(t *testing.T) {
                                        imagFmt += "+"
                                        imagFmt += "10.2"
                                        imagFmt += string(char)
-                                       for _, realSign := range signs {
-                                               for _, imagSign := range signs {
-                                                       one := Sprintf(realFmt, complex(realSign, imagSign))
-                                                       two := Sprintf("("+realFmt+imagFmt+"i)", realSign, imagSign)
+                                       for _, realValue := range values {
+                                               for _, imagValue := range values {
+                                                       one := Sprintf(realFmt, complex(realValue, imagValue))
+                                                       two := Sprintf("("+realFmt+imagFmt+"i)", realValue, imagValue)
                                                        if one != two {
                                                                t.Error(f, one, two)
                                                        }