MCPcopy Index your code
hub / github.com/expr-lang/expr / Errorf

Method Errorf

internal/testify/assert/assertions_test.go:651–685  ·  view source on GitHub ↗
(format string, args ...interface{})

Source from the content-addressed store, hash-verified

649}
650
651func (t *bufferT) Errorf(format string, args ...interface{}) {
652 // implementation of decorate is copied from testing.T
653 decorate := func(s string) string {
654 _, file, line, ok := runtime.Caller(3) // decorate + log + public function.
655 if ok {
656 // Truncate file name at last file name separator.
657 if index := strings.LastIndex(file, "/"); index >= 0 {
658 file = file[index+1:]
659 } else if index = strings.LastIndex(file, "\\"); index >= 0 {
660 file = file[index+1:]
661 }
662 } else {
663 file = "???"
664 line = 1
665 }
666 buf := new(bytes.Buffer)
667 // Every line is indented at least one tab.
668 buf.WriteByte('\t')
669 fmt.Fprintf(buf, "%s:%d: ", file, line)
670 lines := strings.Split(s, "\n")
671 if l := len(lines); l > 1 && lines[l-1] == "" {
672 lines = lines[:l-1]
673 }
674 for i, line := range lines {
675 if i > 0 {
676 // Second and subsequent lines are indented an extra tab.
677 buf.WriteString("\n\t\t")
678 }
679 buf.WriteString(line)
680 }
681 buf.WriteByte('\n')
682 return buf.String()
683 }
684 t.buf.WriteString(decorate(fmt.Sprintf(format, args...)))
685}
686
687func TestStringEqual(t *testing.T) {
688 for i, currCase := range []struct {

Callers

nothing calls this directly

Calls 4

FprintfMethod · 0.80
SplitMethod · 0.80
SprintfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected