Skip to content

Commit 853e420

Browse files
committed
Reversed order of equality checks in equality test, fixed err output.
1 parent 5c92fe2 commit 853e420

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

internal/testutil/cmp.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ func IsDeepEqualTest(t *testing.T, source interface{}, comparison interface{}, c
7878

7979
// IsDeepEqual performs both IsMapVersionDeepEqual and IsStringVersionDeepEqual checks
8080
func IsDeepEqual(source interface{}, comparison interface{}, category string, description string) (bool, error) {
81-
equal := IsMapVersionDeepEqual(source, comparison, category, description)
81+
equal, err := IsStringVersionDeepEqual(source, comparison, category, description)
82+
if err != nil || !equal {
83+
return false, err
84+
}
85+
86+
equal = IsMapVersionDeepEqual(source, comparison, category, description)
8287
if !equal {
8388
return false, nil
8489
}
8590

86-
equal, err := IsStringVersionDeepEqual(source, comparison, category, description)
87-
if err != nil {
88-
return false, err
89-
}
9091
return equal, nil
9192
}
9293

internal/testutil/string.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ func IsStringVersionDeepEqual(source interface{}, comparison interface{}, catego
1414
if start == -1 {
1515
return true, nil // Strings are equal
1616
}
17-
return false, fmt.Errorf("Object values are not equal"+
18-
"String representations deviate starting at index position %d and ending at index position %d of the source string\n"+
17+
return false, fmt.Errorf("object values deviate starting at index position %d and ending at index position %d of the source string\n"+
1918
"Source string: %q\n"+
2019
"Comparison string: %q",
21-
category, description, rStr, eStr,
2220
start, end,
2321
rDiff, eDiff)
2422
}

0 commit comments

Comments
 (0)