forked from newgoo/redigo-pack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bit_test.go
43 lines (37 loc) · 761 Bytes
/
bit_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
package redigo_pack
import (
"github.com/gomodule/redigo/redis"
"testing"
)
func TestBitRds_Bit(t *testing.T) {
NewConnectionByPool(&redis.Pool{})
type bit struct {
key string
offset int64
value int64
}
md := []bit{
{key: "bit_test", offset: 2, value: 1},
{key: "bit_test", offset: 4, value: 1},
{key: "bit_test", offset: 25, value: 1},
}
for _, bt := range md {
RedigoConn.Bit.SetBit(bt.key, bt.offset, bt.value)
}
for _, bt := range md {
v, err := RedigoConn.Bit.GetBit(bt.key, bt.offset).Int64()
if err != nil {
t.Error(err)
}
if v != bt.value {
t.Error(err)
}
}
l, err := RedigoConn.Bit.BitCount(md[0].key).Int()
if err != nil {
t.Error(err)
}
if l != len(md) {
t.Error("bitcout值不正确")
}
}