Skip to content

Instantly share code, notes, and snippets.

@ReSTARTR
Last active August 3, 2019 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ReSTARTR/8922293c9205ea836144040c748a7130 to your computer and use it in GitHub Desktop.
Save ReSTARTR/8922293c9205ea836144040c748a7130 to your computer and use it in GitHub Desktop.
Conventions in Go's Table Driven Tests
func TestFoo(t *testing.T) {
tests := []struct {
in string
out string
}{
{in: "foo", out: "FOO"},
}
for _, tt := range tests {
got := Foo(tt.in)
if got != tt.out {
t.Errorf("got: %s; want: %s", got, tt.out)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment