In itself, this is a very useful idiom. In concrete terms, create a struct type which contains data for a given test case. This ought to include input and expected + actual output. Your test is then a loop over a slice of your test cases, checking expected vs. actual. As the link says, you can see examples of this in tests for the fmt package (link).
One challenge is a nice, clean way to write the actual test, the "assert." Assuming your test method is relatively simple, this ought to do nicely:
if got, want := Foo(input), expected; got != want { t.Errorf("Foo(): got %v, want %v", got, want) }
It is a little boilerplate-y. On the other hand, it's just a few lines and it's very clear what's going on.
You can find examples of this pattern in clone_test.go in the html/template package.
More generally, you can find more interesting test-related patterns from the src/pkg directory of your Go repo: grep 'got != want' `find -name '*.go'`.












