Feat: Add HStrlen Command.

This commit is contained in:
Eriri
2022-05-31 20:13:33 +08:00
committed by finley
parent 951a844439
commit bde2c8ccbe
5 changed files with 31 additions and 4 deletions

View File

@@ -26,7 +26,7 @@ func TestHSet(t *testing.T) {
}
}
// test hget and hexists
// test hget, hexists and hstrlen
for field, v := range values {
actual := testDB.Exec(nil, utils.ToCmdLine("hget", key, field))
expected := protocol.MakeBulkReply(v)
@@ -37,6 +37,11 @@ func TestHSet(t *testing.T) {
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(1) {
t.Error(fmt.Sprintf("expected %d, actually %d", 1, intResult.Code))
}
actual = testDB.Exec(nil, utils.ToCmdLine("hstrlen", key, field))
if intResult, _ := actual.(*protocol.IntReply); intResult.Code != int64(len(v)) {
t.Error(fmt.Sprintf("expected %d, actually %d", int64(len(v)), intResult.Code))
}
}
// test hlen