The Go Blog

golang test

bantana
15 March 2017

cases := []struct {
   in, out string
}{
 {"inData1", "resultData1"},
 {"inData2", "resultData2"},
 {"inData3", "resultData3"},
}

for _, v := range cases { if result := doSomethingFuncOrMethod(v.in) != v.out { t.Errorf("unexpected doSomethingFuncOrMethod(%v) is out: %v", v.in, v.out) } }

Related articles