Table driven tests in Golang

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

Possibly Related Posts