Skip to content

Commit ab9aa4a

Browse files
try to do the whole format string
1 parent 3b0cc42 commit ab9aa4a

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

assert/assertions_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,33 +1644,32 @@ func TestLen(t *testing.T) {
16441644
ch <- 3
16451645

16461646
cases := []struct {
1647-
v interface{}
1648-
l int
1649-
format string
1647+
v interface{}
1648+
l int
1649+
expected1234567 string // message when expecting 1234567 items
16501650
}{
1651-
{[]int{1, 2, 3}, 3, "[1 2 3]"},
1652-
{[...]int{1, 2, 3}, 3, "[1 2 3]"},
1653-
{"ABC", 3, "ABC"},
1654-
{map[int]int{1: 2, 2: 4, 3: 6}, 3, "map[1:2 2:4 3:6]"},
1651+
{[]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`},
1652+
{[...]int{1, 2, 3}, 3, `"[1 2 3]" should have 1234567 item(s), but has 3`},
1653+
{"ABC", 3, `"ABC" should have 1234567 item(s), but has 3`},
1654+
{map[int]int{1: 2, 2: 4, 3: 6}, 3, `"map[1:2 2:4 3:6]" should have 1234567 item(s), but has 3`},
16551655
{ch, 3, ""},
16561656

1657-
{[]int{}, 0, "[]"},
1658-
{map[int]int{}, 0, "map[]"},
1657+
{[]int{}, 0, `"[]" should have 1234567 item(s), but has 0`},
1658+
{map[int]int{}, 0, `"map[]" should have 1234567 item(s), but has 0`},
16591659
{make(chan int), 0, ""},
16601660

1661-
{[]int(nil), 0, "[]"},
1662-
{map[int]int(nil), 0, "map[]"},
1663-
{(chan int)(nil), 0, "<nil>"},
1661+
{[]int(nil), 0, `"[]" should have 1234567 item(s), but has 0`},
1662+
{map[int]int(nil), 0, `"map[]" should have 1234567 item(s), but has 0`},
1663+
{(chan int)(nil), 0, `"<nil>" should have 1234567 item(s), but has 0`},
16641664
}
16651665

16661666
for _, c := range cases {
16671667
True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l)
16681668
False(t, Len(mockT, c.v, c.l+1), "%#v have %d items", c.v, c.l)
1669-
if c.format != "" {
1669+
if c.expected1234567 != "" {
16701670
msgMock := new(mockTestingT)
16711671
Len(msgMock, c.v, 1234567)
1672-
want := fmt.Sprintf(`"%s" should have 1234567 item(s), but has %d`, c.format, c.l)
1673-
Contains(t, msgMock.errorString(), want)
1672+
Contains(t, msgMock.errorString(), c.expected1234567)
16741673
}
16751674
}
16761675
}

0 commit comments

Comments
 (0)