checkers: fix misleading error for c.Check(nil, Equals, "foo") (#114)

With the introduction of the diff code in PR#100 a subtle bug
was introduced. When doing something like:
```
err := c.Check(nil, Equals, osutil.ErrAlreadyLocked)
```
the error is the very misleading:
```
flock_test.go:149:
    c.Assert(nil, Equals, osutil.ErrAlreadyLocked)
... obtained = nil
... expected *errors.errorString = &errors.errorString{s:"cannot acquire lock, already locked"} ("cannot acquire lock, already locked")
... runtime error: invalid memory address or nil pointer dereference
```

This is because the diffworth() code does not properly check for
nil. This PR fixes this and adds some tests around the nil handling
in Equals.
2 files changed
tree: d293fcb19bdb3deacaf589ad37f4534d1342c8ae
  1. .gitignore
  2. .travis.yml
  3. LICENSE
  4. README.md
  5. TODO
  6. benchmark.go
  7. benchmark_test.go
  8. bootstrap_test.go
  9. check.go
  10. check_test.go
  11. checkers.go
  12. checkers_test.go
  13. export_test.go
  14. fixture_test.go
  15. foundation_test.go
  16. helpers.go
  17. helpers_test.go
  18. integration_test.go
  19. printer.go
  20. printer_test.go
  21. reporter.go
  22. reporter_test.go
  23. run.go
  24. run_test.go
README.md

Instructions

Install the package with:

go get gopkg.in/check.v1

Import it with:

import "gopkg.in/check.v1"

and use check as the package name inside the code.

For more details, visit the project page:

and the API documentation: