| 1 | package padding |
| 2 | |
| 3 | import ( |
| 4 | . "gopkg.in/check.v1" |
| 5 | ) |
| 6 | |
| 7 | func (s *TestSuite) TestAlignOneByte(c *C) { |
| 8 | //given |
| 9 | data:=[]byte{1,2,3} |
| 10 | |
| 11 | //when |
| 12 | test:=Align(data,27) |
| 13 | |
| 14 | //then |
| 15 | c.Assert(test, DeepEquals, []byte{0,1,2,3}) |
| 16 | |
| 17 | } |
| 18 | |
| 19 | func (s *TestSuite) TestAlignMultiByte(c *C) { |
| 20 | //given |
| 21 | data:=[]byte{1,2,3} |
| 22 | |
| 23 | //when |
| 24 | test:=Align(data,40) |
| 25 | |
| 26 | //then |
| 27 | c.Assert(test, DeepEquals, []byte{0,0,1,2,3}) |
| 28 | |
| 29 | } |
| 30 | |
| 31 | func (s *TestSuite) TestAlignMultiBytePartial(c *C) { |
| 32 | //given |
| 33 | data:=[]byte{1,2,3} |
| 34 | |
| 35 | //when |
| 36 | test:=Align(data,43) |
| 37 | |
| 38 | //then |
| 39 | c.Assert(test, DeepEquals, []byte{0,0,0,1,2,3}) |
| 40 | |
| 41 | } |
| 42 | |
| 43 | func (s *TestSuite) TestAlignedArray(c *C) { |
| 44 | //given |
| 45 | data:=[]byte{1,2,3} |
| 46 | |
| 47 | //when |
| 48 | test:=Align(data,24) |
| 49 | |
| 50 | //then |
| 51 | c.Assert(test, DeepEquals, []byte{1,2,3}) |
| 52 | } |