correctly treat nils and empty slices in stream.Write

This commit is contained in:
Marten Seemann 2016-08-16 17:25:27 +07:00
parent 4f3f1065cb
commit f0f500a218
2 changed files with 22 additions and 1 deletions

View file

@ -371,6 +371,18 @@ var _ = Describe("Stream", func() {
s[0] = 'v'
Expect(str.getDataForWriting(3)).To(Equal([]byte("foo")))
})
It("returns when given a nil input", func() {
n, err := str.Write(nil)
Expect(n).To(BeZero())
Expect(err).ToNot(HaveOccurred())
})
It("returns when given an empty slice", func() {
n, err := str.Write([]byte(""))
Expect(n).To(BeZero())
Expect(err).ToNot(HaveOccurred())
})
})
Context("closing", func() {