Skip to content

Commit c129115

Browse files
test: Use error.Is(errorType, errorInstance) to check for error equality (TheAlgorithms#666)
Checking error with == operator might fail on wrapped errors
1 parent a52d8bf commit c129115

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

graph/bellmanford_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func TestBellmanford(t *testing.T) {
125125
if resIsReachable != test.isReachable {
126126
t.Errorf("Reachable, Expected: %t, Computed: %t", test.isReachable, resIsReachable)
127127
}
128-
if resError != test.err {
128+
if !errors.Is(test.err, resError) {
129129
if resError == nil || test.err == nil {
130130
t.Errorf("Reachable, Expected: %s, Computed: %s", test.err, resError)
131131
} else if resError.Error() != test.err.Error() {

0 commit comments

Comments
 (0)