-
Notifications
You must be signed in to change notification settings - Fork 0
/
option_test.go
57 lines (52 loc) · 1.02 KB
/
option_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package bitcask
import (
"testing"
"github.com/0rz1/bitcask/cache"
)
func TestCacheOption(t *testing.T) {
opt := &CacheOption{
Capacity: 10,
}
db := &DB{cxt: &context{}}
if err := opt.custom(db); err == nil {
lruc := db.cache.(*cache.LRUCache)
if lruc.Capacity() != opt.Capacity {
t.Error()
}
} else {
t.Error()
}
}
func TestLimitOption(t *testing.T) {
opt := &LimitOption{
MaxFileSize: 10000,
MaxKeySize: 10001,
MaxValueSize: 10002,
}
db := &DB{cxt: &context{}}
if err := opt.custom(db); err == nil {
if db.cxt.limitOpt.MaxFileSize != opt.MaxFileSize {
t.Error()
} else if db.cxt.limitOpt.MaxKeySize != opt.MaxKeySize {
t.Error()
} else if db.cxt.limitOpt.MaxValueSize != opt.MaxValueSize {
t.Error()
}
} else {
t.Error()
}
}
func TestDiskOption(t *testing.T) {
opt := &DiskOption{
ReaderCnt: 10,
LoaderCnt: 1,
}
db := &DB{cxt: &context{}}
if err := opt.custom(db); err == nil {
if db.cxt.diskOpt.ReaderCnt != opt.ReaderCnt {
t.Error()
}
} else {
t.Error()
}
}