aboutsummaryrefslogtreecommitdiff
path: root/src/strconv
diff options
context:
space:
mode:
authorMarcel van Lohuizen <mpvl@golang.org>2019-02-08 17:50:07 +0100
committerMarcel van Lohuizen <mpvl@golang.org>2019-02-27 18:23:19 +0000
commit36b09f334f4d6ca96573b275118bd45db80f3727 (patch)
tree60edef829ffca6b017062efc8afaf24ca85562e0 /src/strconv
parent1413e94178748d369391cb700d76ff4abdd5cf63 (diff)
downloadgo-36b09f334f4d6ca96573b275118bd45db80f3727.tar.gz
go-36b09f334f4d6ca96573b275118bd45db80f3727.zip
strconv: remove use of DeepEqual for testing errors
Comparing errors using DeepEqual breaks if frame information is added as proposed in Issue #29934. Updates #29934. Change-Id: I0372883288f974998138f95f6c7c79a60f922a3e Reviewed-on: https://go-review.googlesource.com/c/162177 Run-TryBot: Marcel van Lohuizen <mpvl@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/strconv')
-rw-r--r--src/strconv/atoi_test.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/strconv/atoi_test.go b/src/strconv/atoi_test.go
index 8b0576b659..b167c96833 100644
--- a/src/strconv/atoi_test.go
+++ b/src/strconv/atoi_test.go
@@ -521,12 +521,22 @@ var parseBaseTests = []parseErrorTest{
{37, baseErrStub},
}
+func equalError(a, b error) bool {
+ if a == nil {
+ return b == nil
+ }
+ if b == nil {
+ return a == nil
+ }
+ return a.Error() == b.Error()
+}
+
func TestParseIntBitSize(t *testing.T) {
for i := range parseBitSizeTests {
test := &parseBitSizeTests[i]
testErr := test.errStub("ParseInt", test.arg)
_, err := ParseInt("0", 0, test.arg)
- if !reflect.DeepEqual(testErr, err) {
+ if !equalError(testErr, err) {
t.Errorf("ParseInt(\"0\", 0, %v) = 0, %v want 0, %v",
test.arg, err, testErr)
}
@@ -538,7 +548,7 @@ func TestParseUintBitSize(t *testing.T) {
test := &parseBitSizeTests[i]
testErr := test.errStub("ParseUint", test.arg)
_, err := ParseUint("0", 0, test.arg)
- if !reflect.DeepEqual(testErr, err) {
+ if !equalError(testErr, err) {
t.Errorf("ParseUint(\"0\", 0, %v) = 0, %v want 0, %v",
test.arg, err, testErr)
}
@@ -550,7 +560,7 @@ func TestParseIntBase(t *testing.T) {
test := &parseBaseTests[i]
testErr := test.errStub("ParseInt", test.arg)
_, err := ParseInt("0", test.arg, 0)
- if !reflect.DeepEqual(testErr, err) {
+ if !equalError(testErr, err) {
t.Errorf("ParseInt(\"0\", %v, 0) = 0, %v want 0, %v",
test.arg, err, testErr)
}
@@ -562,7 +572,7 @@ func TestParseUintBase(t *testing.T) {
test := &parseBaseTests[i]
testErr := test.errStub("ParseUint", test.arg)
_, err := ParseUint("0", test.arg, 0)
- if !reflect.DeepEqual(testErr, err) {
+ if !equalError(testErr, err) {
t.Errorf("ParseUint(\"0\", %v, 0) = 0, %v want 0, %v",
test.arg, err, testErr)
}