fix tiny bugs

This commit is contained in:
finley
2023-02-20 22:43:45 +08:00
parent fb7208c017
commit 7f6edf817e
2 changed files with 11 additions and 3 deletions

View File

@@ -208,10 +208,18 @@ func TestExpiredTime(t *testing.T) {
testDB.Exec(nil, utils.ToCmdLine("EXPIRE", key, "2"))
//tt := time.Now()
result = testDB.Exec(nil, utils.ToCmdLine("ttl", key))
asserts.AssertIntReply(t, result, 2)
intResult, ok := result.(*protocol.IntReply)
if !ok {
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
return
}
if intResult.Code < 0 || intResult.Code > 2 {
t.Errorf("expected ttl more than 0, actual: %d", intResult.Code)
return
}
result = testDB.Exec(nil, utils.ToCmdLine("EXPIRETIME", key))
asserts.AssertIntReply(t, result, int(time.Now().Add(2*time.Second).Unix()))
intResult, ok := result.(*protocol.IntReply)
intResult, ok = result.(*protocol.IntReply)
if !ok {
t.Error(fmt.Sprintf("expected int protocol, actually %s", result.ToBytes()))
return

View File

@@ -74,7 +74,7 @@ func (b *BitMap) ForEachBit(begin int64, end int64, cb Callback) {
}
bitOffset++
offset++
if offset >= end {
if offset >= end && end != 0 {
break
}
}