Jamie Hannaford | b2b237f | 2014-09-15 12:17:47 +0200 | [diff] [blame] | 1 | package testhelper |
| 2 | |
| 3 | import "testing" |
| 4 | |
Jamie Hannaford | 2964aed | 2014-09-15 12:20:02 +0200 | [diff] [blame^] | 5 | // This function compares two arbitrary values and performs a comparison. If the |
| 6 | // comparison fails, a fatal error is raised that will fail the test |
Jamie Hannaford | b2b237f | 2014-09-15 12:17:47 +0200 | [diff] [blame] | 7 | func Compare(t *testing.T, expected interface{}, actual interface{}) { |
| 8 | if expected != actual { |
| 9 | t.Fatalf("Expected [%#v] but got [%#v]", expected, actual) |
| 10 | } |
| 11 | } |
| 12 | |
Jamie Hannaford | 2964aed | 2014-09-15 12:20:02 +0200 | [diff] [blame^] | 13 | // A convenience function for checking whether an error value is an actual error |
Jamie Hannaford | b2b237f | 2014-09-15 12:17:47 +0200 | [diff] [blame] | 14 | func CheckErr(t *testing.T, e error) { |
| 15 | if e != nil { |
| 16 | t.Fatalf("Unexpected error: %#v", e) |
| 17 | } |
| 18 | } |