~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/pkg/strings/reader_test.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
package strings_test
6
6
 
7
7
import (
 
8
        "bytes"
8
9
        "fmt"
9
10
        "io"
10
11
        "os"
86
87
                }
87
88
        }
88
89
}
 
90
 
 
91
func TestWriteTo(t *testing.T) {
 
92
        const str = "0123456789"
 
93
        for i := 0; i <= len(str); i++ {
 
94
                s := str[i:]
 
95
                r := strings.NewReader(s)
 
96
                var b bytes.Buffer
 
97
                n, err := r.WriteTo(&b)
 
98
                if expect := int64(len(s)); n != expect {
 
99
                        t.Errorf("got %v; want %v", n, expect)
 
100
                }
 
101
                if err != nil {
 
102
                        t.Errorf("for length %d: got error = %v; want nil", len(s), err)
 
103
                }
 
104
                if b.String() != s {
 
105
                        t.Errorf("got string %q; want %q", b.String(), s)
 
106
                }
 
107
                if r.Len() != 0 {
 
108
                        t.Errorf("reader contains %v bytes; want 0", r.Len())
 
109
                }
 
110
        }
 
111
}