MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / TestTable_AddRow_WithNewLines

Function TestTable_AddRow_WithNewLines

internal/table/table_test.go:183–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

181}
182
183func 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
207fizz buzz
208
209cat
210bippity boppity
211 boop
212a b
213c d
2141 x
2152 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
223func TestTable_SetRows(t *testing.T) {
224 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.70
AddRowMethod · 0.65
WithWriterMethod · 0.65
PrintMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected