diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-03-04 21:27:36 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-04 21:27:36 +0100 |
commit | 04b08da9af0c450d645ab7389d1467308cfc2db8 (patch) | |
tree | db247935fa4f2f94408edc3acd5d0d4f997aa0d8 /src/pkg/strings/reader_test.go | |
parent | 917c5fb8ec48e22459d77e3849e6d388f93d3260 (diff) | |
download | golang-upstream/1.1_hg20130304.tar.gz |
Imported Upstream version 1.1~hg20130304upstream/1.1_hg20130304
Diffstat (limited to 'src/pkg/strings/reader_test.go')
-rw-r--r-- | src/pkg/strings/reader_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pkg/strings/reader_test.go b/src/pkg/strings/reader_test.go index a99ae2a0e..4fdddcdb5 100644 --- a/src/pkg/strings/reader_test.go +++ b/src/pkg/strings/reader_test.go @@ -5,6 +5,7 @@ package strings_test import ( + "bytes" "fmt" "io" "os" @@ -86,3 +87,25 @@ func TestReaderAt(t *testing.T) { } } } + +func TestWriteTo(t *testing.T) { + const str = "0123456789" + for i := 0; i <= len(str); i++ { + s := str[i:] + r := strings.NewReader(s) + var b bytes.Buffer + n, err := r.WriteTo(&b) + if expect := int64(len(s)); n != expect { + t.Errorf("got %v; want %v", n, expect) + } + if err != nil { + t.Errorf("for length %d: got error = %v; want nil", len(s), err) + } + if b.String() != s { + t.Errorf("got string %q; want %q", b.String(), s) + } + if r.Len() != 0 { + t.Errorf("reader contains %v bytes; want 0", r.Len()) + } + } +} |