Skip to content

Commit d5be414

Browse files
committed
Don't change the format of failure messages when fixing 1525
1 parent 28dac59 commit d5be414

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

assert/assertions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
11081108
}
11091109
}
11101110

1111-
return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%#v", subset), truncatingFormat("%#v", list)), msgAndArgs...)
1111+
return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%q", subset), truncatingFormat("%q", list)), msgAndArgs...)
11121112
}
11131113

11141114
subsetList := reflect.ValueOf(subset)
@@ -1130,7 +1130,7 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{})
11301130
}
11311131
}
11321132

1133-
return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%#v", subset), truncatingFormat("%#v", list)), msgAndArgs...)
1133+
return Fail(t, fmt.Sprintf("%s is a subset of %s", truncatingFormat("%q", subset), truncatingFormat("%q", list)), msgAndArgs...)
11341134
}
11351135

11361136
// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified

assert/assertions_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,19 +1202,19 @@ func TestSubsetNotSubset(t *testing.T) {
12021202
}{
12031203
// cases that are expected to contain
12041204
{[]int{1, 2, 3}, nil, true, `nil is the empty set which is a subset of every set`},
1205-
{[]int{1, 2, 3}, []int{}, true, `[]int{} is a subset of []int{1, 2, 3}`},
1206-
{[]int{1, 2, 3}, []int{1, 2}, true, `[]int{1, 2} is a subset of []int{1, 2, 3}`},
1207-
{[]int{1, 2, 3}, []int{1, 2, 3}, true, `[]int{1, 2, 3} is a subset of []int{1, 2, 3}`},
1208-
{[]string{"hello", "world"}, []string{"hello"}, true, `[]string{"hello"} is a subset of []string{"hello", "world"}`},
1205+
{[]int{1, 2, 3}, []int{}, true, `[] is a subset of ['\x01' '\x02' '\x03']`},
1206+
{[]int{1, 2, 3}, []int{1, 2}, true, `['\x01' '\x02'] is a subset of ['\x01' '\x02' '\x03']`},
1207+
{[]int{1, 2, 3}, []int{1, 2, 3}, true, `['\x01' '\x02' '\x03'] is a subset of ['\x01' '\x02' '\x03']`},
1208+
{[]string{"hello", "world"}, []string{"hello"}, true, `["hello"] is a subset of ["hello" "world"]`},
12091209
{map[string]string{
12101210
"a": "x",
12111211
"c": "z",
12121212
"b": "y",
12131213
}, map[string]string{
12141214
"a": "x",
12151215
"b": "y",
1216-
}, true, `map[string]string{"a":"x", "b":"y"} is a subset of map[string]string{"a":"x", "b":"y", "c":"z"}`},
1217-
{[]string{"a", "b", "c"}, map[string]int{"a": 1, "c": 3}, true, `map[string]int{"a":1, "c":3} is a subset of []string{"a", "b", "c"}`},
1216+
}, true, `map["a":"x" "b":"y"] is a subset of map["a":"x" "b":"y" "c":"z"]`},
1217+
{[]string{"a", "b", "c"}, map[string]int{"a": 1, "c": 3}, true, `map["a":'\x01' "c":'\x03'] is a subset of ["a" "b" "c"]`},
12181218

12191219
// cases that are expected not to contain
12201220
{[]string{"hello", "world"}, []string{"hello", "testify"}, false, `[]string{"hello", "world"} does not contain "testify"`},
@@ -4032,19 +4032,19 @@ func TestNotSubsetWithSliceTooLongToPrint(t *testing.T) {
40324032
NotSubset(mockT, longSlice, longSlice)
40334033
Contains(t, mockT.errorString(), `
40344034
Error Trace:
4035-
Error: []int{0, 0, 0,`)
4036-
Contains(t, mockT.errorString(), `<... truncated> is a subset of []int{0, 0, 0,`)
4035+
Error: ['\x00' '\x00' '\x00'`)
4036+
Contains(t, mockT.errorString(), `<... truncated> is a subset of ['\x00' '\x00' '\x00'`)
40374037
}
40384038

40394039
func TestNotSubsetWithMapTooLongToPrint(t *testing.T) {
40404040
t.Parallel()
40414041
mockT := new(mockTestingT)
40424042
longSlice := make([]int, 1_000_000)
4043-
NotSubset(mockT, map[bool][]int{true: longSlice}, map[bool][]int{true: longSlice})
4043+
NotSubset(mockT, map[int][]int{1: longSlice}, map[int][]int{1: longSlice})
40444044
Contains(t, mockT.errorString(), `
40454045
Error Trace:
4046-
Error: map[bool][]int{true:[]int{0, 0, 0,`)
4047-
Contains(t, mockT.errorString(), `<... truncated> is a subset of map[bool][]int{true:[]int{0, 0, 0,`)
4046+
Error: map['\x01':['\x00' '\x00' '\x00'`)
4047+
Contains(t, mockT.errorString(), `<... truncated> is a subset of map['\x01':['\x00' '\x00' '\x00'`)
40484048
}
40494049

40504050
func TestSameWithSliceTooLongToPrint(t *testing.T) {

0 commit comments

Comments
 (0)