From: Martin Möhrmann Date: Sat, 12 Aug 2017 20:15:43 +0000 (+0200) Subject: strconv: avoid truncation of output in parse int tests X-Git-Tag: go1.10beta1~1627 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=09ed0f68059552abeeae78867ffc2956205df22a;p=gostls13.git strconv: avoid truncation of output in parse int tests If needed cast the test table values to a higher bit size integer type instead of casting the result values of the tested function to a lower bit size integer type. Change-Id: Iaa79742b2b1d90c7c7eac324f54032ebea0b1b41 Reviewed-on: https://go-review.googlesource.com/55137 Reviewed-by: Joe Tsai --- diff --git a/src/strconv/atoi_test.go b/src/strconv/atoi_test.go index 9cef025941..77814eaa5a 100644 --- a/src/strconv/atoi_test.go +++ b/src/strconv/atoi_test.go @@ -307,7 +307,7 @@ func TestParseUint(t *testing.T) { for i := range atoui32tests { test := &atoui32tests[i] out, err := ParseUint(test.in, 10, 0) - if test.out != uint32(out) || !reflect.DeepEqual(test.err, err) { + if uint64(test.out) != out || !reflect.DeepEqual(test.err, err) { t.Errorf("Atoui(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } @@ -316,7 +316,7 @@ func TestParseUint(t *testing.T) { for i := range atoui64tests { test := &atoui64tests[i] out, err := ParseUint(test.in, 10, 0) - if test.out != uint64(out) || !reflect.DeepEqual(test.err, err) { + if test.out != out || !reflect.DeepEqual(test.err, err) { t.Errorf("Atoui(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } @@ -330,7 +330,7 @@ func TestParseInt(t *testing.T) { for i := range atoi32tests { test := &atoi32tests[i] out, err := ParseInt(test.in, 10, 0) - if test.out != int32(out) || !reflect.DeepEqual(test.err, err) { + if int64(test.out) != out || !reflect.DeepEqual(test.err, err) { t.Errorf("Atoi(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) } @@ -339,7 +339,7 @@ func TestParseInt(t *testing.T) { for i := range atoi64tests { test := &atoi64tests[i] out, err := ParseInt(test.in, 10, 0) - if test.out != int64(out) || !reflect.DeepEqual(test.err, err) { + if test.out != out || !reflect.DeepEqual(test.err, err) { t.Errorf("Atoi(%q) = %v, %v want %v, %v", test.in, out, err, test.out, test.err) }