~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/io/multi_test.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        "crypto/sha1"
10
10
        "fmt"
11
11
        . "io"
 
12
        "io/ioutil"
12
13
        "strings"
13
14
        "testing"
14
15
)
86
87
                t.Errorf("expected %q; got %q", sourceString, sink.String())
87
88
        }
88
89
}
 
90
 
 
91
// Test that MultiReader copies the input slice and is insulated from future modification.
 
92
func TestMultiReaderCopy(t *testing.T) {
 
93
        slice := []Reader{strings.NewReader("hello world")}
 
94
        r := MultiReader(slice...)
 
95
        slice[0] = nil
 
96
        data, err := ioutil.ReadAll(r)
 
97
        if err != nil || string(data) != "hello world" {
 
98
                t.Errorf("ReadAll() = %q, %v, want %q, nil", data, err, "hello world")
 
99
        }
 
100
}
 
101
 
 
102
// Test that MultiWriter copies the input slice and is insulated from future modification.
 
103
func TestMultiWriterCopy(t *testing.T) {
 
104
        var buf bytes.Buffer
 
105
        slice := []Writer{&buf}
 
106
        w := MultiWriter(slice...)
 
107
        slice[0] = nil
 
108
        n, err := w.Write([]byte("hello world"))
 
109
        if err != nil || n != 11 {
 
110
                t.Errorf("Write(`hello world`) = %d, %v, want 11, nil", n, err)
 
111
        }
 
112
        if buf.String() != "hello world" {
 
113
                t.Errorf("buf.String() = %q, want %q", buf.String(), "hello world")
 
114
        }
 
115
}