Table driven tests in Golang

Mar. 28, 2018

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