github.com/neatlab/neatio@v1.7.3-0.20220425043230-d903e92fcc75/utilities/compression/rle/read_write_test.go (about) 1 package rle 2 3 import ( 4 "testing" 5 6 checker "gopkg.in/check.v1" 7 ) 8 9 func Test(t *testing.T) { checker.TestingT(t) } 10 11 type CompressionRleSuite struct{} 12 13 var _ = checker.Suite(&CompressionRleSuite{}) 14 15 func (s *CompressionRleSuite) TestDecompressSimple(c *checker.C) { 16 exp := []byte{0xc5, 0xd2, 0x46, 0x1, 0x86, 0xf7, 0x23, 0x3c, 0x92, 0x7e, 0x7d, 0xb2, 0xdc, 0xc7, 0x3, 0xc0, 0xe5, 0x0, 0xb6, 0x53, 0xca, 0x82, 0x27, 0x3b, 0x7b, 0xfa, 0xd8, 0x4, 0x5d, 0x85, 0xa4, 0x70} 17 res, err := Decompress([]byte{token, 0xfd}) 18 c.Assert(err, checker.IsNil) 19 c.Assert(res, checker.DeepEquals, exp) 20 21 exp = []byte{0x56, 0xe8, 0x1f, 0x17, 0x1b, 0xcc, 0x55, 0xa6, 0xff, 0x83, 0x45, 0xe6, 0x92, 0xc0, 0xf8, 0x6e, 0x5b, 0x48, 0xe0, 0x1b, 0x99, 0x6c, 0xad, 0xc0, 0x1, 0x62, 0x2f, 0xb5, 0xe3, 0x63, 0xb4, 0x21} 22 res, err = Decompress([]byte{token, 0xfe}) 23 c.Assert(err, checker.IsNil) 24 c.Assert(res, checker.DeepEquals, exp) 25 26 res, err = Decompress([]byte{token, 0xff}) 27 c.Assert(err, checker.IsNil) 28 c.Assert(res, checker.DeepEquals, []byte{token}) 29 30 res, err = Decompress([]byte{token, 12}) 31 c.Assert(err, checker.IsNil) 32 c.Assert(res, checker.DeepEquals, make([]byte, 10)) 33 34 }