(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func TestFormatBinaryDateTime(t *testing.T) { |
| 58 | rawDate := [11]byte{} |
| 59 | binary.LittleEndian.PutUint16(rawDate[:2], 1978) // years |
| 60 | rawDate[2] = 12 // months |
| 61 | rawDate[3] = 30 // days |
| 62 | rawDate[4] = 15 // hours |
| 63 | rawDate[5] = 46 // minutes |
| 64 | rawDate[6] = 23 // seconds |
| 65 | binary.LittleEndian.PutUint32(rawDate[7:], 987654) // microseconds |
| 66 | expect := func(expected string, inlen, outlen uint8) { |
| 67 | actual, _ := formatBinaryDateTime(rawDate[:inlen], outlen) |
| 68 | bytes, ok := actual.([]byte) |
| 69 | if !ok { |
| 70 | t.Errorf("formatBinaryDateTime must return []byte, was %T", actual) |
| 71 | } |
| 72 | if string(bytes) != expected { |
| 73 | t.Errorf( |
| 74 | "expected %q, got %q for length in %d, out %d", |
| 75 | expected, actual, inlen, outlen, |
| 76 | ) |
| 77 | } |
| 78 | } |
| 79 | expect("0000-00-00", 0, 10) |
| 80 | expect("0000-00-00 00:00:00", 0, 19) |
| 81 | expect("1978-12-30", 4, 10) |
| 82 | expect("1978-12-30 15:46:23", 7, 19) |
| 83 | expect("1978-12-30 15:46:23.987654", 11, 26) |
| 84 | } |
| 85 | |
| 86 | func TestFormatBinaryTime(t *testing.T) { |
| 87 | expect := func(expected string, src []byte, outlen uint8) { |
nothing calls this directly
no test coverage detected