(t *testing.T)
| 181 | } |
| 182 | |
| 183 | func TestTable_AddRow_WithNewLines(t *testing.T) { |
| 184 | t.Parallel() |
| 185 | |
| 186 | buf := bytes.Buffer{} |
| 187 | tbl := New("foo", "bar").WithWriter(&buf).AddRow("fizz", "buzz") |
| 188 | |
| 189 | // Add some rows |
| 190 | tbl.AddRow() |
| 191 | tbl.AddRow("cat") |
| 192 | |
| 193 | // add an entry that contains new lines |
| 194 | tbl.AddRow("bippity", "boppity\nboop") |
| 195 | |
| 196 | // Add a couple more rows |
| 197 | tbl.AddRow("a", "b") |
| 198 | tbl.AddRow("c", "d") |
| 199 | |
| 200 | // and another entry with more new lines |
| 201 | tbl.AddRow("1\n2", "x\ny\nz") |
| 202 | |
| 203 | // check the full table |
| 204 | buf.Reset() |
| 205 | tbl.Print() |
| 206 | expected := `foo bar |
| 207 | fizz buzz |
| 208 | |
| 209 | cat |
| 210 | bippity boppity |
| 211 | boop |
| 212 | a b |
| 213 | c d |
| 214 | 1 x |
| 215 | 2 y |
| 216 | z |
| 217 | ` |
| 218 | if diff := cmp.Diff(expected, buf.String()); diff != "" { |
| 219 | t.Fatalf("table mismatch (-expected +got):\n%s\nout=%#v", diff, buf.String()) |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | func TestTable_SetRows(t *testing.T) { |
| 224 | t.Parallel() |
nothing calls this directly
no test coverage detected