(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestGenerateTriangle(t *testing.T) { |
| 14 | tests := []struct { |
| 15 | name string |
| 16 | n int |
| 17 | want [][]int |
| 18 | }{ |
| 19 | {name: "Pascal's three-line triangle", n: 3, want: [][]int{{1}, {1, 1}, {1, 2, 1}}}, |
| 20 | {name: "Pascal's 0-line triangle", n: 0, want: [][]int{}}, |
| 21 | {name: "Pascal's one-line triangle", n: 1, want: [][]int{{1}}}, |
| 22 | {name: "Pascal's 7-line triangle", n: 7, want: [][]int{{1}, {1, 1}, {1, 2, 1}, {1, 3, 3, 1}, {1, 4, 6, 4, 1}, {1, 5, 10, 10, 5, 1}, {1, 6, 15, 20, 15, 6, 1}}}, |
| 23 | } |
| 24 | for _, test := range tests { |
| 25 | t.Run(test.name, func(t *testing.T) { |
| 26 | if got := GenerateTriangle(test.n); !reflect.DeepEqual(got, test.want) { |
| 27 | t.Errorf("GenerateTriangle() = %v, want %v", got, test.want) |
| 28 | } |
| 29 | }) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | func BenchmarkGenerateTriangle(b *testing.B) { |
| 34 | for i := 0; i < b.N; i++ { |
nothing calls this directly
no test coverage detected