github.com/segmentio/parquet-go@v0.0.0-20230712180008-5d42db8f0d47/encoding/delta/delta_test.go (about)

     1  //go:build go1.18
     2  // +build go1.18
     3  
     4  package delta_test
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  
    10  	"github.com/segmentio/parquet-go/encoding/delta"
    11  	"github.com/segmentio/parquet-go/encoding/fuzz"
    12  	"github.com/segmentio/parquet-go/encoding/test"
    13  )
    14  
    15  func FuzzDeltaBinaryPackedInt32(f *testing.F) {
    16  	fuzz.EncodeInt32(f, new(delta.BinaryPackedEncoding))
    17  }
    18  
    19  func FuzzDeltaBinaryPackedInt64(f *testing.F) {
    20  	fuzz.EncodeInt64(f, new(delta.BinaryPackedEncoding))
    21  }
    22  
    23  func FuzzDeltaLengthByteArray(f *testing.F) {
    24  	fuzz.EncodeByteArray(f, new(delta.LengthByteArrayEncoding))
    25  }
    26  
    27  func FuzzDeltaByteArray(f *testing.F) {
    28  	fuzz.EncodeByteArray(f, new(delta.ByteArrayEncoding))
    29  }
    30  
    31  const (
    32  	encodeMinNumValues = 0
    33  	encodeMaxNumValues = 200
    34  )
    35  
    36  func TestEncodeInt32(t *testing.T) {
    37  	for bitWidth := uint(0); bitWidth <= 32; bitWidth++ {
    38  		t.Run(fmt.Sprintf("bitWidth=%d", bitWidth), func(t *testing.T) {
    39  			test.EncodeInt32(t,
    40  				new(delta.BinaryPackedEncoding),
    41  				encodeMinNumValues,
    42  				encodeMaxNumValues,
    43  				bitWidth,
    44  			)
    45  		})
    46  	}
    47  }
    48  
    49  func TestEncodeInt64(t *testing.T) {
    50  	for bitWidth := uint(0); bitWidth <= 64; bitWidth++ {
    51  		t.Run(fmt.Sprintf("bitWidth=%d", bitWidth), func(t *testing.T) {
    52  			test.EncodeInt64(t,
    53  				new(delta.BinaryPackedEncoding),
    54  				encodeMinNumValues,
    55  				encodeMaxNumValues,
    56  				bitWidth,
    57  			)
    58  		})
    59  	}
    60  }