mirror of
https://github.com/golang/go
synced 2024-11-17 18:04:48 -07: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
@ -746,7 +746,7 @@ func TestNewWriterSizeIdempotent(t *testing.T) {
|
||||
|
||||
func TestWriteString(t *testing.T) {
|
||||
const BufSize = 8
|
||||
buf := new(bytes.Buffer)
|
||||
buf := new(strings.Builder)
|
||||
b := NewWriterSize(buf, BufSize)
|
||||
b.WriteString("0") // easy
|
||||
b.WriteString("123456") // still easy
|
||||
@ -757,8 +757,8 @@ func TestWriteString(t *testing.T) {
|
||||
t.Error("WriteString", err)
|
||||
}
|
||||
s := "01234567890abcdefghijklmnopqrstuvwxyz"
|
||||
if string(buf.Bytes()) != s {
|
||||
t.Errorf("WriteString wants %q gets %q", s, string(buf.Bytes()))
|
||||
if buf.String() != s {
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user