cmd/segment-reaper: Rename Bitmask to BitArray

Rename a test name and an error class because the bitmask was renamed to
bitArray in a previous commit, however, they weren't updated.

Change-Id: I92afcf747dec9e0a15d4c59b896e07b942f3518b
This commit is contained in:
Ivan Fraixedes 2020-05-11 16:19:34 +02:00
parent 50e8314279
commit 9314092841
No known key found for this signature in database
GPG Key ID: 042B474597F96DB7
2 changed files with 10 additions and 10 deletions

View File

@ -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
}

View File

@ -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")
})
})
}