diff --git a/database/keys_test.go b/database/keys_test.go index 0e1508e..b62aa93 100644 --- a/database/keys_test.go +++ b/database/keys_test.go @@ -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 diff --git a/datastruct/bitmap/bitmap.go b/datastruct/bitmap/bitmap.go index 4a234ca..5cf33f2 100644 --- a/datastruct/bitmap/bitmap.go +++ b/datastruct/bitmap/bitmap.go @@ -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 } }