mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
bufio: use strings.Builder
Change-Id: Ia8d6cea75b32c8839837c1bb1e13cde9b236abdd Reviewed-on: https://go-review.googlesource.com/c/go/+/435939 Run-TryBot: xie cui <523516579@qq.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
45c2421dc6
commit
e3ac2152f2
1 changed files with 4 additions and 4 deletions
|
@ -746,7 +746,7 @@ func TestNewWriterSizeIdempotent(t *testing.T) {
|
||||||
|
|
||||||
func TestWriteString(t *testing.T) {
|
func TestWriteString(t *testing.T) {
|
||||||
const BufSize = 8
|
const BufSize = 8
|
||||||
buf := new(bytes.Buffer)
|
buf := new(strings.Builder)
|
||||||
b := NewWriterSize(buf, BufSize)
|
b := NewWriterSize(buf, BufSize)
|
||||||
b.WriteString("0") // easy
|
b.WriteString("0") // easy
|
||||||
b.WriteString("123456") // still easy
|
b.WriteString("123456") // still easy
|
||||||
|
@ -757,8 +757,8 @@ func TestWriteString(t *testing.T) {
|
||||||
t.Error("WriteString", err)
|
t.Error("WriteString", err)
|
||||||
}
|
}
|
||||||
s := "01234567890abcdefghijklmnopqrstuvwxyz"
|
s := "01234567890abcdefghijklmnopqrstuvwxyz"
|
||||||
if string(buf.Bytes()) != s {
|
if buf.String() != s {
|
||||||
t.Errorf("WriteString wants %q gets %q", s, string(buf.Bytes()))
|
t.Errorf("WriteString wants %q gets %q", s, buf.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1389,7 +1389,7 @@ func TestWriterReadFromUntilEOF(t *testing.T) {
|
||||||
t.Fatalf("ReadFrom returned (%v, %v), want (4, nil)", n2, err)
|
t.Fatalf("ReadFrom returned (%v, %v), want (4, nil)", n2, err)
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
if got, want := string(buf.Bytes()), "0123abcd"; got != want {
|
if got, want := buf.String(), "0123abcd"; got != want {
|
||||||
t.Fatalf("buf.Bytes() returned %q, want %q", got, want)
|
t.Fatalf("buf.Bytes() returned %q, want %q", got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue