MCPcopy Index your code
hub / github.com/cockroachdb/errors / TestPrintEntry

Function TestPrintEntry

errbase/format_error_internal_test.go:304–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestPrintEntry(t *testing.T) {
305 b := func(s string) []byte { return []byte(s) }
306
307 testCases := []struct {
308 entry formatEntry
309 exp string
310 }{
311 {formatEntry{}, ""},
312 {formatEntry{head: b("abc")}, " abc"},
313 {formatEntry{head: b("abc\nxyz")}, " abc\nxyz"},
314 {formatEntry{details: b("def")}, " def"},
315 {formatEntry{details: b("def\nxyz")}, " def\nxyz"},
316 {formatEntry{head: b("abc"), details: b("def")}, " abcdef"},
317 {formatEntry{head: b("abc\nxyz"), details: b("def")}, " abc\nxyzdef"},
318 {formatEntry{head: b("abc"), details: b("def\n | xyz")}, " abcdef\n | xyz"},
319 {formatEntry{head: b("abc\nxyz"), details: b("def\n | xyz")}, " abc\nxyzdef\n | xyz"},
320 }
321
322 for _, tc := range testCases {
323 s := state{}
324 s.printEntry(tc.entry)
325 if s.finalBuf.String() != tc.exp {
326 t.Errorf("%s: expected %q, got %q", tc.entry, tc.exp, s.finalBuf.String())
327 }
328 }
329}
330
331func TestFormatSingleLineOutput(t *testing.T) {
332 b := func(s string) []byte { return []byte(s) }

Callers

nothing calls this directly

Calls 2

printEntryMethod · 0.95
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…