1package testy 2 3import "testing" 4 5func TestTableTests(t *testing.T) { 6 addFunc := func(a, b int) int { 7 return a + b 8 } 9 type ttTest struct { 10 a, b int 11 output int 12 } 13 table := NewTable() 14 table.Add("one", func(_ *testing.T) interface{} { 15 return ttTest{a: 1, output: 1} 16 }) 17 table.Add("two", ttTest{a: 1, b: 1, output: 2}) 18 table.Add("three", func() interface{} { 19 return ttTest{a: 1, b: 2, output: 3} 20 }) 21 table.Run(t, func(t *testing.T, test ttTest) { 22 output := addFunc(test.a, test.b) 23 if output != test.output { 24 t.Errorf("Expected %d, got %d\n", test.output, output) 25 } 26 }) 27} 28