Example #1
0
func (S) TestFromBytesWithBadData(c *C) {
	for i, test := range fromBytesBadData {
		var prefix []byte
		if (test.header & 1) != 0 {
			prefix = []byte{test.header, 1, 2, 3, 'i', 'd', 'A'} // With time.
		} else {
			prefix = []byte{test.header, 1, 3, 'i', 'd', 'A'} // Without time.
		}
		value := bytes.Join([][]byte{prefix, test.suffix}, []byte{})
		vc, err := vclock.FromBytes(value)
		c.Assert(err, ErrorMatches, test.error, Commentf("%#d failed", i))
		c.Assert(vc, IsNil)
	}
}
Example #2
0
func testFromBytes(c *C, vc1 *vclock.VClock) {
	vc1Bytes := vc1.Bytes()
	vc2, err := vclock.FromBytes(vc1Bytes)
	c.Assert(err, Equals, nil)
	c.Assert(vc2.Bytes(), DeepEquals, vc1Bytes)
}