mirror of
https://github.com/golang/go
synced 2024-11-17 05:35:00 -07:00
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>
This commit is contained in:
parent
1413e94178
commit
36b09f334f
@ -521,12 +521,22 @@ var parseBaseTests = []parseErrorTest{
|
|||||||
{37, baseErrStub},
|
{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) {
|
func TestParseIntBitSize(t *testing.T) {
|
||||||
for i := range parseBitSizeTests {
|
for i := range parseBitSizeTests {
|
||||||
test := &parseBitSizeTests[i]
|
test := &parseBitSizeTests[i]
|
||||||
testErr := test.errStub("ParseInt", test.arg)
|
testErr := test.errStub("ParseInt", test.arg)
|
||||||
_, err := ParseInt("0", 0, 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",
|
t.Errorf("ParseInt(\"0\", 0, %v) = 0, %v want 0, %v",
|
||||||
test.arg, err, testErr)
|
test.arg, err, testErr)
|
||||||
}
|
}
|
||||||
@ -538,7 +548,7 @@ func TestParseUintBitSize(t *testing.T) {
|
|||||||
test := &parseBitSizeTests[i]
|
test := &parseBitSizeTests[i]
|
||||||
testErr := test.errStub("ParseUint", test.arg)
|
testErr := test.errStub("ParseUint", test.arg)
|
||||||
_, err := ParseUint("0", 0, 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",
|
t.Errorf("ParseUint(\"0\", 0, %v) = 0, %v want 0, %v",
|
||||||
test.arg, err, testErr)
|
test.arg, err, testErr)
|
||||||
}
|
}
|
||||||
@ -550,7 +560,7 @@ func TestParseIntBase(t *testing.T) {
|
|||||||
test := &parseBaseTests[i]
|
test := &parseBaseTests[i]
|
||||||
testErr := test.errStub("ParseInt", test.arg)
|
testErr := test.errStub("ParseInt", test.arg)
|
||||||
_, err := ParseInt("0", test.arg, 0)
|
_, 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",
|
t.Errorf("ParseInt(\"0\", %v, 0) = 0, %v want 0, %v",
|
||||||
test.arg, err, testErr)
|
test.arg, err, testErr)
|
||||||
}
|
}
|
||||||
@ -562,7 +572,7 @@ func TestParseUintBase(t *testing.T) {
|
|||||||
test := &parseBaseTests[i]
|
test := &parseBaseTests[i]
|
||||||
testErr := test.errStub("ParseUint", test.arg)
|
testErr := test.errStub("ParseUint", test.arg)
|
||||||
_, err := ParseUint("0", test.arg, 0)
|
_, 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",
|
t.Errorf("ParseUint(\"0\", %v, 0) = 0, %v want 0, %v",
|
||||||
test.arg, err, testErr)
|
test.arg, err, testErr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user