diff --git a/cmd/segment-reaper/bitmask.go b/cmd/segment-reaper/bit_array.go similarity index 87% rename from cmd/segment-reaper/bitmask.go rename to cmd/segment-reaper/bit_array.go index 3272f981a..f77315c38 100644 --- a/cmd/segment-reaper/bitmask.go +++ b/cmd/segment-reaper/bit_array.go @@ -9,9 +9,9 @@ import ( "github.com/zeebo/errs" ) -// errorBitmaskInvalidIdx is the error class to return invalid indexes for the +// errorBitArrayInvalidIdx is the error class to return invalid indexes for the // the bitArray type. -var errorBitmaskInvalidIdx = errs.Class("invalid index") +var errorBitArrayInvalidIdx = errs.Class("invalid index") // bitArray allows easy access to bit values by indices. type bitArray []byte @@ -22,7 +22,7 @@ func (bytes *bitArray) Set(index int) error { bitIndex, byteIndex := index%8, index/8 switch { case index < 0: - return errorBitmaskInvalidIdx.New("negative value (%d)", index) + return errorBitArrayInvalidIdx.New("negative value (%d)", index) case byteIndex >= len(*bytes): sizeToGrow := byteIndex - len(*bytes) + 1 *bytes = append(*bytes, make([]byte, sizeToGrow)...) @@ -37,7 +37,7 @@ func (bytes *bitArray) Unset(index int) error { bitIndex, byteIndex := index%8, index/8 switch { case index < 0: - return errorBitmaskInvalidIdx.New("negative value (%d)", index) + return errorBitArrayInvalidIdx.New("negative value (%d)", index) case byteIndex >= len(*bytes): return nil } @@ -52,7 +52,7 @@ func (bytes *bitArray) Has(index int) (bool, error) { bitIndex, byteIndex := index%8, index/8 switch { case index < 0: - return false, errorBitmaskInvalidIdx.New("negative value (%d)", index) + return false, errorBitArrayInvalidIdx.New("negative value (%d)", index) case byteIndex >= len(*bytes): return false, nil } diff --git a/cmd/segment-reaper/bitmask_test.go b/cmd/segment-reaper/bit_array_test.go similarity index 94% rename from cmd/segment-reaper/bitmask_test.go rename to cmd/segment-reaper/bit_array_test.go index eb7a0ed36..9e900e785 100644 --- a/cmd/segment-reaper/bitmask_test.go +++ b/cmd/segment-reaper/bit_array_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestBitmask(t *testing.T) { +func TestBitArray(t *testing.T) { t.Run("Set", func(t *testing.T) { t.Run("ok", func(t *testing.T) { var ( @@ -33,7 +33,7 @@ func TestBitmask(t *testing.T) { err := bits.Set(invalidIdx) assert.Error(t, err) - assert.True(t, errorBitmaskInvalidIdx.Has(err), "errorBitmaskInvalidIdx class") + assert.True(t, errorBitArrayInvalidIdx.Has(err), "errorBitArrayInvalidIdx class") }) t.Run("error: index > 63", func(t *testing.T) { @@ -44,7 +44,7 @@ func TestBitmask(t *testing.T) { err := bits.Set(invalidIdx) assert.NoError(t, err) - assert.False(t, errorBitmaskInvalidIdx.Has(err), "errorBitmaskInvalidIdx class") + assert.False(t, errorBitArrayInvalidIdx.Has(err), "errorBitArrayInvalidIdx class") }) }) @@ -68,7 +68,7 @@ func TestBitmask(t *testing.T) { _, err := bits.Has(invalidIdx) assert.Error(t, err) - assert.True(t, errorBitmaskInvalidIdx.Has(err), "errorBitmaskInvalidIdx class") + assert.True(t, errorBitArrayInvalidIdx.Has(err), "errorBitArrayInvalidIdx class") }) }) @@ -318,7 +318,7 @@ func TestBitmask(t *testing.T) { err := bits.Unset(invalidIdx) assert.Error(t, err) - assert.True(t, errorBitmaskInvalidIdx.Has(err), "errorBitmaskInvalidIdx class") + assert.True(t, errorBitArrayInvalidIdx.Has(err), "errorBitArrayInvalidIdx class") }) }) }