github.com/parquet-go/parquet-go@v0.20.0/encoding/delta/length_byte_array_test.go (about) 1 package delta 2 3 import "testing" 4 5 func TestDecodeByteArrayLengths(t *testing.T) { 6 lengths := make([]int32, 999) 7 offsets := make([]uint32, len(lengths)+1) 8 9 totalLength := uint32(0) 10 for i := range lengths { 11 lengths[i] = int32(i) 12 totalLength += uint32(i) 13 } 14 15 lastOffset, invalidLength := decodeByteArrayLengths(offsets, lengths) 16 if invalidLength != 0 { 17 t.Fatal("wrong invalid length:", invalidLength) 18 } 19 if lastOffset != totalLength { 20 t.Fatalf("wrong last offset: want=%d got=%d", lastOffset, totalLength) 21 } 22 23 expectOffset := uint32(0) 24 for i, offset := range offsets[:len(lengths)] { 25 if offset != expectOffset { 26 t.Fatalf("wrong offset at index %d: want=%d got=%d", i, expectOffset, offset) 27 } 28 expectOffset += uint32(lengths[i]) 29 } 30 31 if offsets[len(lengths)] != lastOffset { 32 t.Fatalf("wrong last offset: want=%d got=%d", lastOffset, offsets[len(lengths)]) 33 } 34 }