-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions_test.go
40 lines (33 loc) · 961 Bytes
/
options_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package fastcdc
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestOptionsSizeTooSmall(t *testing.T) {
options, err := WithAverageSize(128, 0)
assert.ErrorIs(t, err, ErrInvalidSize)
assert.Nil(t, options)
}
func TestOptionsSizeTooLarge(t *testing.T) {
options, err := WithAverageSize(5<<20, 0)
assert.ErrorIs(t, err, ErrInvalidSize)
assert.Nil(t, options)
}
func TestOptionsNormNegative(t *testing.T) {
options, err := WithAverageSize(256, -1)
assert.ErrorIs(t, err, ErrInvalidNorm)
assert.Nil(t, options)
}
func TestOptionsNormTooLarge(t *testing.T) {
options, err := WithAverageSize(256, 4)
assert.ErrorIs(t, err, ErrInvalidNorm)
assert.Nil(t, options)
}
func TestOptionsSizeConfig(t *testing.T) {
options, err := WithAverageSize(256, 2)
require.NoError(t, err)
assert.Equal(t, options.minSize, 64)
assert.Equal(t, options.maxSize, 1024)
assert.Equal(t, options.avgSize, 256)
}