From: Marcel van Lohuizen Date: Fri, 8 Feb 2019 16:50:07 +0000 (+0100) Subject: strconv: remove use of DeepEqual for testing errors X-Git-Tag: go1.13beta1~1325 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=36b09f334f4d6ca96573b275118bd45db80f3727;p=gostls13.git 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 TryBot-Result: Gobot Gobot Reviewed-by: Russ Cox Reviewed-by: Damien Neil --- 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) }