|
|
|
@ -12,20 +12,21 @@ func TestRecord_readAndWrite(t *testing.T) {
|
|
|
|
|
offset := rand.Int63n(128)
|
|
|
|
|
walID := rand.Int63()
|
|
|
|
|
data := make([]byte, rand.Intn(128))
|
|
|
|
|
segID := rand.Int63()
|
|
|
|
|
|
|
|
|
|
buf := make([]byte, recOffsetData+len(data)+int(offset))
|
|
|
|
|
|
|
|
|
|
rec1 := writeWALRecord(buf, offset, walID, data)
|
|
|
|
|
rec1 := writeWALRecord(segID, buf, offset, walID, data)
|
|
|
|
|
|
|
|
|
|
// Expected values.
|
|
|
|
|
nextOffset := int64(recOffsetData+len(data)) + offset
|
|
|
|
|
dataLen := uint32(len(data))
|
|
|
|
|
size := uint32(recOffsetData + len(data))
|
|
|
|
|
|
|
|
|
|
rec2 := readWALRecord(buf, offset, nil)
|
|
|
|
|
rec2 := readWALRecord(segID, buf, offset, nil)
|
|
|
|
|
|
|
|
|
|
for _, rec := range []*Record{rec1, rec2} {
|
|
|
|
|
if rec.segID != 0 {
|
|
|
|
|
if rec.segID != segID {
|
|
|
|
|
t.Fatal(rec.segID)
|
|
|
|
|
}
|
|
|
|
|
if rec.offset != offset {
|
|
|
|
|