blob: 091ad1c1f674ff16b718ffc54a7949324822af50 (
plain) (
blame)
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
|
package pktline
import (
"io/ioutil"
. "gopkg.in/check.v1"
)
type EncoderSuite struct{}
var _ = Suite(&EncoderSuite{})
func (s *EncoderSuite) TestEncode(c *C) {
line, err := Encode([]byte("a\n"))
c.Assert(err, IsNil)
c.Assert(string(line), Equals, "0006a\n")
}
func (s *EncoderSuite) TestEncodeFromString(c *C) {
line, err := EncodeFromString("a\n")
c.Assert(err, IsNil)
c.Assert(string(line), Equals, "0006a\n")
}
func (s *EncoderSuite) TestEncoder(c *C) {
e := NewEncoder()
e.AddLine("a")
e.AddFlush()
e.AddLine("b")
r := e.GetReader()
a, _ := ioutil.ReadAll(r)
c.Assert(string(a), Equals, "0006a\n00000006b\n")
}
|