From 5d7303c49ac984a9fec60523f2d5297682e16646 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Ortiz Date: Sun, 5 Apr 2015 23:34:43 +0200 Subject: some refactor in folders and crawler --- pktline/encoder_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pktline/encoder_test.go (limited to 'pktline/encoder_test.go') diff --git a/pktline/encoder_test.go b/pktline/encoder_test.go new file mode 100644 index 0000000..091ad1c --- /dev/null +++ b/pktline/encoder_test.go @@ -0,0 +1,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") +} -- cgit