aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/bufio_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-11-01 19:00:05 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2017-11-02 17:17:44 +0000
commit6128ff84f1106af4944f50f74070566e87f2cb35 (patch)
tree19f4190f9b21681e268988d41a475a9eef01904b /src/bufio/bufio_test.go
parent2da1446bb11cdfaac1f86d7c2134c36487dd2d66 (diff)
downloadgo-6128ff84f1106af4944f50f74070566e87f2cb35.tar.xz
bufio: add Reader.Size and Writer.Size accessors
Fixes #21343 Change-Id: I3582fced902592fe12bfa29acf7b40b6e5e554a7 Reviewed-on: https://go-review.googlesource.com/75150 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/bufio/bufio_test.go')
-rw-r--r--src/bufio/bufio_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bufio/bufio_test.go b/src/bufio/bufio_test.go
index ef0f6c834e..c829d2b064 100644
--- a/src/bufio/bufio_test.go
+++ b/src/bufio/bufio_test.go
@@ -1418,6 +1418,24 @@ func TestReaderDiscard(t *testing.T) {
}
+func TestReaderSize(t *testing.T) {
+ if got, want := NewReader(nil).Size(), DefaultBufSize; got != want {
+ t.Errorf("NewReader's Reader.Size = %d; want %d", got, want)
+ }
+ if got, want := NewReaderSize(nil, 1234).Size(), 1234; got != want {
+ t.Errorf("NewReaderSize's Reader.Size = %d; want %d", got, want)
+ }
+}
+
+func TestWriterSize(t *testing.T) {
+ if got, want := NewWriter(nil).Size(), DefaultBufSize; got != want {
+ t.Errorf("NewWriter's Writer.Size = %d; want %d", got, want)
+ }
+ if got, want := NewWriterSize(nil, 1234).Size(), 1234; got != want {
+ t.Errorf("NewWriterSize's Writer.Size = %d; want %d", got, want)
+ }
+}
+
// An onlyReader only implements io.Reader, no matter what other methods the underlying implementation may have.
type onlyReader struct {
io.Reader