aboutsummaryrefslogtreecommitdiffstats
path: root/pktline/encoder_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros Ortiz <mcuadros@gmail.com>2015-04-05 23:34:43 +0200
committerMáximo Cuadros Ortiz <mcuadros@gmail.com>2015-04-06 04:12:04 +0200
commit5d7303c49ac984a9fec60523f2d5297682e16646 (patch)
tree53ac3a7eae7e271e58cc37ab1b7d2c27f3f2a9e5 /pktline/encoder_test.go
downloadgo-git-5d7303c49ac984a9fec60523f2d5297682e16646.tar.gz
some refactor in folders and crawler
Diffstat (limited to 'pktline/encoder_test.go')
-rw-r--r--pktline/encoder_test.go34
1 files changed, 34 insertions, 0 deletions
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")
+}