aboutsummaryrefslogtreecommitdiffstats
path: root/formats/pktline/decoder_test.go
diff options
context:
space:
mode:
authorAlberto Cortés <alcortesm@gmail.com>2016-10-18 15:23:01 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-10-18 15:23:01 +0200
commit5f7d34066cc5583ee30a315e0661b5326dc548db (patch)
treec10fdbf1f42d5b51de25c6828ba6573dd28f4536 /formats/pktline/decoder_test.go
parent6c6a37b9128189ba4cdde8128428a36ef75d1a44 (diff)
downloadgo-git-5f7d34066cc5583ee30a315e0661b5326dc548db.tar.gz
Substitute old pktline encoder/decoder with new pktline scanner (#84)
* replace old pktline package with new pktline scanner * remove error checks on pktline.NewFromString * fix deppend bug * reduce memory garbage when pktline.NewFromStrings * improve int to hex conversion to help gc * make intToHex func private * clean function names
Diffstat (limited to 'formats/pktline/decoder_test.go')
-rw-r--r--formats/pktline/decoder_test.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/formats/pktline/decoder_test.go b/formats/pktline/decoder_test.go
deleted file mode 100644
index e3cd2f4..0000000
--- a/formats/pktline/decoder_test.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package pktline
-
-import (
- "strings"
- "testing"
-
- . "gopkg.in/check.v1"
-)
-
-func Test(t *testing.T) { TestingT(t) }
-
-type DecoderSuite struct{}
-
-var _ = Suite(&DecoderSuite{})
-
-func (s *DecoderSuite) TestReadLine(c *C) {
- j := NewDecoder(strings.NewReader("0006a\n"))
-
- line, err := j.ReadLine()
- c.Assert(err, IsNil)
- c.Assert(line, Equals, "a\n")
-}
-
-func (s *DecoderSuite) TestReadLineInvalidHeader(c *C) {
- j := NewDecoder(strings.NewReader("foo\n"))
-
- _, err := j.ReadLine()
- c.Assert(err, Equals, ErrInvalidHeader)
-}
-
-func (s *DecoderSuite) TestReadLineBufferUnderflow(c *C) {
- j := NewDecoder(strings.NewReader("00e7a\n"))
-
- line, err := j.ReadLine()
- c.Assert(err, Equals, ErrUnderflow)
- c.Assert(line, Equals, "")
-}
-
-func (s *DecoderSuite) TestReadLineInvalidLen(c *C) {
- j := NewDecoder(strings.NewReader("0001foo\n"))
-
- line, err := j.ReadLine()
- c.Assert(err, Equals, ErrInvalidLen)
- c.Assert(line, Equals, "")
-}
-
-func (s *DecoderSuite) TestReadBlock(c *C) {
- j := NewDecoder(strings.NewReader("0006a\n"))
-
- lines, err := j.ReadBlock()
- c.Assert(err, IsNil)
- c.Assert(lines, HasLen, 1)
- c.Assert(lines[0], Equals, "a\n")
-}
-
-func (s *DecoderSuite) TestReadBlockWithFlush(c *C) {
- j := NewDecoder(strings.NewReader("0006a\n0006b\n00000006c\n"))
-
- lines, err := j.ReadBlock()
- c.Assert(err, IsNil)
- c.Assert(lines, HasLen, 2)
- c.Assert(lines[0], Equals, "a\n")
- c.Assert(lines[1], Equals, "b\n")
-}
-
-func (s *DecoderSuite) TestReadBlockInvalidLen(c *C) {
- j := NewDecoder(strings.NewReader("0001foo\n"))
-
- lines, err := j.ReadBlock()
- c.Assert(err, Equals, ErrInvalidLen)
- c.Assert(lines, HasLen, 0)
-}
-
-func (s *DecoderSuite) TestReadAll(c *C) {
- j := NewDecoder(strings.NewReader("0006a\n0006b\n00000006c\n0006d\n0006e\n"))
-
- lines, err := j.ReadAll()
- c.Assert(err, IsNil)
- c.Assert(lines, HasLen, 5)
- c.Assert(lines[0], Equals, "a\n")
- c.Assert(lines[1], Equals, "b\n")
- c.Assert(lines[2], Equals, "c\n")
- c.Assert(lines[3], Equals, "d\n")
- c.Assert(lines[4], Equals, "e\n")
-}