(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestLengthEncodedInteger(t *testing.T) { |
| 21 | var integerTests = []struct { |
| 22 | num uint64 |
| 23 | encoded []byte |
| 24 | }{ |
| 25 | {0x0000000000000000, []byte{0x00}}, |
| 26 | {0x0000000000000012, []byte{0x12}}, |
| 27 | {0x00000000000000fa, []byte{0xfa}}, |
| 28 | {0x0000000000000100, []byte{0xfc, 0x00, 0x01}}, |
| 29 | {0x0000000000001234, []byte{0xfc, 0x34, 0x12}}, |
| 30 | {0x000000000000ffff, []byte{0xfc, 0xff, 0xff}}, |
| 31 | {0x0000000000010000, []byte{0xfd, 0x00, 0x00, 0x01}}, |
| 32 | {0x0000000000123456, []byte{0xfd, 0x56, 0x34, 0x12}}, |
| 33 | {0x0000000000ffffff, []byte{0xfd, 0xff, 0xff, 0xff}}, |
| 34 | {0x0000000001000000, []byte{0xfe, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}}, |
| 35 | {0x123456789abcdef0, []byte{0xfe, 0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12}}, |
| 36 | {0xffffffffffffffff, []byte{0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}, |
| 37 | } |
| 38 | |
| 39 | for _, tst := range integerTests { |
| 40 | num, isNull, numLen := readLengthEncodedInteger(tst.encoded) |
| 41 | if isNull { |
| 42 | t.Errorf("%x: expected %d, got NULL", tst.encoded, tst.num) |
| 43 | } |
| 44 | if num != tst.num { |
| 45 | t.Errorf("%x: expected %d, got %d", tst.encoded, tst.num, num) |
| 46 | } |
| 47 | if numLen != len(tst.encoded) { |
| 48 | t.Errorf("%x: expected size %d, got %d", tst.encoded, len(tst.encoded), numLen) |
| 49 | } |
| 50 | encoded := appendLengthEncodedInteger(nil, num) |
| 51 | if !bytes.Equal(encoded, tst.encoded) { |
| 52 | t.Errorf("%v: expected %x, got %x", num, tst.encoded, encoded) |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | func TestFormatBinaryDateTime(t *testing.T) { |
| 58 | rawDate := [11]byte{} |
nothing calls this directly
no test coverage detected