1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package sideband
import (
"bytes"
. "gopkg.in/check.v1"
)
func (s *SidebandSuite) TestMuxerWrite(c *C) {
buf := bytes.NewBuffer(nil)
m := NewMuxer(Sideband, buf)
n, err := m.Write(bytes.Repeat([]byte{'F'}, (MaxPackedSize-1)*2))
c.Assert(err, IsNil)
c.Assert(n, Equals, 1998)
c.Assert(buf.Len(), Equals, 2008)
}
func (s *SidebandSuite) TestMuxerWriteChannelMultipleChannels(c *C) {
buf := bytes.NewBuffer(nil)
m := NewMuxer(Sideband, buf)
n, err := m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4))
c.Assert(err, IsNil)
c.Assert(n, Equals, 4)
n, err = m.WriteChannel(ProgressMessage, bytes.Repeat([]byte{'P'}, 4))
c.Assert(err, IsNil)
c.Assert(n, Equals, 4)
n, err = m.WriteChannel(PackData, bytes.Repeat([]byte{'D'}, 4))
c.Assert(err, IsNil)
c.Assert(n, Equals, 4)
c.Assert(buf.Len(), Equals, 27)
c.Assert(buf.String(), Equals, "0009\x01DDDD0009\x02PPPP0009\x01DDDD")
}
|