Last active
June 3, 2020 23:16
-
-
Save lukasmalkmus/de529eb6dcb68ab9c204ed1e55786674 to your computer and use it in GitHub Desktop.
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
import ( | |
"reflect" | |
"testing" | |
) | |
// assert fails the test if the condition is false. | |
func assert(tb testing.TB, condition bool, msg string, v ...interface{}) { | |
tb.Helper() | |
if !condition { | |
tb.Fatalf("\033[31m "+msg+"\033[39m\n\n", v...) | |
} | |
} | |
// ok fails the test if an err is not nil. | |
func ok(tb testing.TB, err error) { | |
tb.Helper() | |
if err != nil { | |
tb.Fatalf("\033[31m unexpected error: %s\033[39m\n\n", err) | |
} | |
} | |
// equals fails the test if got is not equal to want. | |
func equals(tb testing.TB, got, want interface{}) { | |
tb.Helper() | |
if !reflect.DeepEqual(got, want) { | |
tb.Fatalf("\033[31m\n\n\tgot: %#v\n\n\twant: %#v\033[39m\n\n", got, want) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment