MCPcopy
hub / github.com/stretchr/testify / indentMessageLines

Function indentMessageLines

assert/assertions.go:325–338  ·  view source on GitHub ↗

Aligns the provided message so that all lines after the first line start at the same location as the first line. Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). The longestLabelLen parameter specifies the length of the longest label in

(message string, longestLabelLen int)

Source from the content-addressed store, hash-verified

323// The longestLabelLen parameter specifies the length of the longest label in the output (required because this is the
324// basis on which the alignment occurs).
325func indentMessageLines(message string, longestLabelLen int) string {
326 outBuf := new(bytes.Buffer)
327
328 for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ {
329 // no need to align first line because it starts at the correct location (after the label)
330 if i != 0 {
331 // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab
332 outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t")
333 }
334 outBuf.WriteString(scanner.Text())
335 }
336
337 return outBuf.String()
338}
339
340type failNower interface {
341 FailNow()

Callers 1

labeledOutputFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected