When `len(actual) > len(expected)`, this for loop would cause a panic.
Alternative to this implementation, there could be a check for
`if len(actual) != len(expected)`, but generating a meaningful message
describing that is already provided by `diff()`. So we defer to diff in
every case.
Fixes#393
Pre-diff:
```
panic: runtime error: index out of range
```
Post-diff:
```
panic:
mock: Unexpected Method Call
-----------------------------
MyFunction(string,string,string)
0: string,
1: string,
2: string
The closest call I have is:
MyFunction(string,string)
0: "mock.Anything"
1: "mock.Anything"
Provided 3 arguments, mocked for 2 arguments
```
Some dependencies no longer support go <= 1.3.
github.com/davecgh/go-spew/spew and github.com/stretchr/objx depend on
the "bytes" package, and github.com/pmezard/go-difflib/difflib depends
on the "bufio" package.
This change removes them from tested platforms in travis. It may make
sense to explicitly doc the lack of support elsewhere.
Previous implementation depended on tab alignment. This worked
when the output was not prepended with anything, but would break
if the output was prepended with further spaces (which can occur
in environments like IntelliJ test runners). This commit fixes it
so that the output is always aligned logically.
Fixes#83
- NoError prints the error message on the next line, unquoted, which makes multiline error messages much clearer. Sample of an error message which includes a multiline stacktrace:
Error: Received unexpected error:
Hi!
/Volumes/Pouch/Users/russegan/dev/go/src/gitlab.protectv.local/ncryptify/client.git/client_test.go:27 (0x75c8c)
TestNew: assert.NoError(merry.New("Hi!"), "with message")
/usr/local/Cellar/go/1.7rc1/libexec/src/testing/testing.go:610 (0x70a01)
tRunner: fn(t)
/usr/local/Cellar/go/1.7rc1/libexec/src/runtime/asm_amd64.s:2086 (0x5d131)
goexit: BYTE $0x90 // NOP
Messages: with message
- Error,NoError,and EqualError now don’t inline the user’s extra messages. user’s messages are printed in the “Messages:” section, as with all other assertions.
- EqualError now avoids isNil(), mirroring the changes already made to Error and NoError.
- Equal, EqualValues, and EqualError now print the expected and actual values each on a newline, aligned vertically, which makes it easier for a human to visually detect the differences. Examples:
Error: Error message not equal:
expected: ”no failure"
recieved: “failure"
Messages: with message
Error: Not equal:
"high" (expected)
"low" (actual)
Messages: with message
- EqualValues uses the same value formatting and diff output as Equal for consistency