| 749 | func (bufferT) Helper() {} |
| 750 | |
| 751 | func (t *bufferT) Errorf(format string, args ...interface{}) { |
| 752 | // implementation of decorate is copied from testing.T |
| 753 | decorate := func(s string) string { |
| 754 | _, file, line, ok := runtime.Caller(3) // decorate + log + public function. |
| 755 | if ok { |
| 756 | // Truncate file name at last file name separator. |
| 757 | if index := strings.LastIndex(file, "/"); index >= 0 { |
| 758 | file = file[index+1:] |
| 759 | } else if index = strings.LastIndex(file, "\\"); index >= 0 { |
| 760 | file = file[index+1:] |
| 761 | } |
| 762 | } else { |
| 763 | file = "???" |
| 764 | line = 1 |
| 765 | } |
| 766 | buf := new(bytes.Buffer) |
| 767 | // Every line is indented at least one tab. |
| 768 | buf.WriteByte('\t') |
| 769 | fmt.Fprintf(buf, "%s:%d: ", file, line) |
| 770 | lines := strings.Split(s, "\n") |
| 771 | if l := len(lines); l > 1 && lines[l-1] == "" { |
| 772 | lines = lines[:l-1] |
| 773 | } |
| 774 | for i, line := range lines { |
| 775 | if i > 0 { |
| 776 | // Second and subsequent lines are indented an extra tab. |
| 777 | buf.WriteString("\n\t\t") |
| 778 | } |
| 779 | buf.WriteString(line) |
| 780 | } |
| 781 | buf.WriteByte('\n') |
| 782 | return buf.String() |
| 783 | } |
| 784 | t.buf.WriteString(decorate(fmt.Sprintf(format, args...))) |
| 785 | } |
| 786 | |
| 787 | func TestStringEqual(t *testing.T) { |
| 788 | t.Parallel() |