checkTable to check if a table contains cells
(t *testing.T, tb *datatable.DataTable, cells ...interface{})
| 9 | |
| 10 | // checkTable to check if a table contains cells |
| 11 | func checkTable(t *testing.T, tb *datatable.DataTable, cells ...interface{}) { |
| 12 | ncols := tb.NumCols() |
| 13 | nrows := tb.NumRows() |
| 14 | assert.Len(t, cells, ncols*(nrows+1)) // + headers |
| 15 | |
| 16 | cols := tb.Columns() |
| 17 | rows := tb.Rows() |
| 18 | |
| 19 | for i, v := range cells { |
| 20 | r := i/ncols - 1 |
| 21 | c := i % ncols |
| 22 | |
| 23 | if r == -1 { |
| 24 | assert.Equal(t, v, cols[c], "HEADER COL #%d", r, c) |
| 25 | continue |
| 26 | } |
| 27 | |
| 28 | assert.Equal(t, v, rows[r][cols[c]], "ROW #%d, COL #%d", r, c) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | func New(t *testing.T) *datatable.DataTable { |
| 33 | tb := datatable.New("test") |
no test coverage detected