Table driven tests in Golang

1
2
3
4
5
6
7
8
9
10
11
12
var fibTests = []struct {
n int // input
expected int // expected result
}{
{1, 1},
{2, 1},
{3, 2},
{4, 3},
{5, 5},
{6, 8},
{7, 13},
}

source: 5 simple tips and tricks for writing unit tests in #golang