Created
November 18, 2019 09:03
-
-
Save avrebarra/f4148a3eeefc33b7cd48bb3aefb73f11 to your computer and use it in GitHub Desktop.
Golang Basic Testing Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package some_test | |
import ( | |
"testing" | |
) | |
// Credits to (Cory Jacobsen) from this file here https://github.com/unrolled/render/blob/7fc1b8f68b9beddc94385fd212c293caf729277a/render_test.go#L44 | |
/* Test Helper */ | |
func expect(t *testing.T, a interface{}, b interface{}) { | |
if a != b { | |
t.Errorf("Expected ||%#v|| (type %v) - Got ||%#v|| (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) | |
} | |
} | |
func expectNil(t *testing.T, a interface{}) { | |
if a != nil { | |
t.Errorf("Expected ||nil|| - Got ||%#v|| (type %v)", a, reflect.TypeOf(a)) | |
} | |
} | |
func expectNotNil(t *testing.T, a interface{}) { | |
if a == nil { | |
t.Errorf("Expected ||not nil|| - Got ||nil|| (type %v)", reflect.TypeOf(a)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment