-
Notifications
You must be signed in to change notification settings - Fork 3
/
valuememblock_GEN_test.go
49 lines (47 loc) · 1.23 KB
/
valuememblock_GEN_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
package store
import (
"math"
"testing"
)
func TestValueValuesMemRead(t *testing.T) {
store, _ := newTestValueStore(nil)
memBlock1 := &valueMemBlock{id: 1, store: store, values: []byte("0123456789abcdef")}
memBlock2 := &valueMemBlock{id: 2, store: store, values: []byte("fedcba9876543210")}
store.locBlocks = []valueLocBlock{nil, memBlock1, memBlock2}
tsn := memBlock1.timestampnano()
if tsn != math.MaxInt64 {
t.Fatal(tsn)
}
ts, v, err := memBlock1.read(1, 2, 0x100, 5, 6, nil)
if !IsNotFound(err) {
t.Fatal(err)
}
memBlock1.store.locmap.Set(1, 2, 0x100, memBlock1.id, 5, 6, false)
ts, v, err = memBlock1.read(1, 2, 0x100, 5, 6, nil)
if err != nil {
a, b, c, d := memBlock1.store.locmap.Get(1, 2)
t.Fatal(err, a, b, c, d)
}
if ts != 0x100 {
t.Fatal(ts)
}
if string(v) != "56789a" {
t.Fatal(string(v))
}
memBlock1.store.locmap.Set(1, 2, 0x100|_TSB_DELETION, memBlock1.id, 5, 6, false)
ts, v, err = memBlock1.read(1, 2, 0x100, 5, 6, nil)
if !IsNotFound(err) {
t.Fatal(err)
}
memBlock1.store.locmap.Set(1, 2, 0x200, memBlock2.id, 5, 6, false)
ts, v, err = memBlock1.read(1, 2, 0x100, 5, 6, nil)
if err != nil {
t.Fatal(err)
}
if ts != 0x200 {
t.Fatal(ts)
}
if string(v) != "a98765" {
t.Fatal(string(v))
}
}