mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
mime: use strings.Builder
Change-Id: I2756fab046154a2df49435ba1978a32176de830a Reviewed-on: https://go-review.googlesource.com/c/go/+/428265 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: xie cui <523516579@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
3b044e9c7e
commit
e0e0c8fe98
@ -5,7 +5,6 @@
|
||||
package multipart
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"math"
|
||||
"os"
|
||||
@ -92,7 +91,7 @@ func testFile(t *testing.T, fh *FileHeader, efn, econtent string) File {
|
||||
if err != nil {
|
||||
t.Fatal("opening file:", err)
|
||||
}
|
||||
b := new(bytes.Buffer)
|
||||
b := new(strings.Builder)
|
||||
_, err = io.Copy(b, f)
|
||||
if err != nil {
|
||||
t.Fatal("copying contents:", err)
|
||||
|
@ -126,7 +126,7 @@ func TestMultipartSlowInput(t *testing.T) {
|
||||
func testMultipart(t *testing.T, r io.Reader, onlyNewlines bool) {
|
||||
t.Parallel()
|
||||
reader := NewReader(r, "MyBoundary")
|
||||
buf := new(bytes.Buffer)
|
||||
buf := new(strings.Builder)
|
||||
|
||||
// Part1
|
||||
part, err := reader.NextPart()
|
||||
@ -416,7 +416,7 @@ func TestLineContinuation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("didn't get a part")
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
n, err := io.Copy(&buf, part)
|
||||
if err != nil {
|
||||
t.Errorf("error reading part: %v\nread so far: %q", err, buf.String())
|
||||
@ -446,7 +446,7 @@ func testQuotedPrintableEncoding(t *testing.T, cte string) {
|
||||
if te, ok := part.Header["Content-Transfer-Encoding"]; ok {
|
||||
t.Errorf("unexpected Content-Transfer-Encoding of %q", te)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
_, err = io.Copy(&buf, part)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@ -484,7 +484,7 @@ Content-Transfer-Encoding: quoted-printable
|
||||
if _, ok := part.Header["Content-Transfer-Encoding"]; !ok {
|
||||
t.Errorf("missing Content-Transfer-Encoding")
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
_, err = io.Copy(&buf, part)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
@ -993,7 +993,7 @@ func roundTripParseTest() parseTest {
|
||||
formData("foo", "bar"),
|
||||
},
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
w := NewWriter(&buf)
|
||||
for _, p := range t.want {
|
||||
pw, err := w.CreatePart(p.header)
|
||||
|
@ -98,7 +98,7 @@ func TestWriterSetBoundary(t *testing.T) {
|
||||
{"(boundary)", true},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
var b bytes.Buffer
|
||||
var b strings.Builder
|
||||
w := NewWriter(&b)
|
||||
err := w.SetBoundary(tt.b)
|
||||
got := err == nil
|
||||
@ -145,7 +145,7 @@ func TestWriterBoundaryGoroutines(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSortedHeader(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
w := NewWriter(&buf)
|
||||
if err := w.SetBoundary("MIMEBOUNDARY"); err != nil {
|
||||
t.Fatalf("Error setting mime boundary: %v", err)
|
||||
|
@ -6,7 +6,6 @@ package quotedprintable
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
@ -69,7 +68,7 @@ func TestReader(t *testing.T) {
|
||||
want: "accept UTF-8 right quotation mark: ’"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
_, err := io.Copy(&buf, NewReader(strings.NewReader(tt.in)))
|
||||
if got := buf.String(); got != tt.want {
|
||||
t.Errorf("for %q, got %q; want %q", tt.in, got, tt.want)
|
||||
@ -114,7 +113,7 @@ func TestExhaustive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
var buf strings.Builder
|
||||
res := make(map[string]int)
|
||||
n := 6
|
||||
if testing.Short() {
|
||||
|
@ -91,7 +91,7 @@ func testWriter(t *testing.T, binary bool) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
buf := new(bytes.Buffer)
|
||||
buf := new(strings.Builder)
|
||||
w := NewWriter(buf)
|
||||
|
||||
want := tt.want
|
||||
|
Loading…
Reference in New Issue
Block a user