fix(zset): fixed zrevrange support of WITHSCORES.

Added zrevrange test case zset_family_test.cc.
Fixes #106
This commit is contained in:
Ansore 2022-06-12 16:21:18 +08:00 committed by GitHub
parent d0af04d427
commit f7d3f4d640
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -1889,7 +1889,7 @@ void ZSetFamily::Register(CommandRegistry* registry) {
<< CI{"ZREMRANGEBYRANK", CO::WRITE, 4, 1, 1, 1}.HFUNC(ZRemRangeByRank)
<< CI{"ZREMRANGEBYSCORE", CO::WRITE, 4, 1, 1, 1}.HFUNC(ZRemRangeByScore)
<< CI{"ZREMRANGEBYLEX", CO::WRITE, 4, 1, 1, 1}.HFUNC(ZRemRangeByLex)
<< CI{"ZREVRANGE", CO::READONLY, 4, 1, 1, 1}.HFUNC(ZRevRange)
<< CI{"ZREVRANGE", CO::READONLY, -4, 1, 1, 1}.HFUNC(ZRevRange)
<< CI{"ZREVRANGEBYSCORE", CO::READONLY, -4, 1, 1, 1}.HFUNC(ZRevRangeByScore)
<< CI{"ZREVRANK", CO::READONLY | CO::FAST, 3, 1, 1, 1}.HFUNC(ZRevRank)
<< CI{"ZSCAN", CO::READONLY | CO::RANDOM, -3, 1, 1, 1}.HFUNC(ZScan)

View file

@ -142,6 +142,14 @@ TEST_F(ZSetFamilyTest, ZRevRange) {
resp = Run({"zrevrangebyscore", "key", "2", "-inf", "withscores"});
ASSERT_THAT(resp, ArrLen(6));
EXPECT_THAT(resp.GetVec(), ElementsAre("c", "2", "b", "1", "a", "-inf"));
resp = Run({"zrevrange", "key", "0", "2"});
ASSERT_THAT(resp, ArrLen(3));
EXPECT_THAT(resp.GetVec(), ElementsAre("c", "b", "a"));
resp = Run({"zrevrange", "key", "1", "2", "withscores"});
ASSERT_THAT(resp, ArrLen(4));
EXPECT_THAT(resp.GetVec(), ElementsAre("b", "1", "a", "-inf"));
}
TEST_F(ZSetFamilyTest, ZScan) {