Skip to content

Commit 2957add

Browse files
author
prvyk
committed
Add testcases.
1 parent 5a67b08 commit 2957add

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/Garnet.test/RespSortedSetTests.cs

+29
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ public void AddWithOptions()
189189
var added = db.SortedSetAdd(key, entries);
190190
ClassicAssert.AreEqual(entries.Length, added);
191191

192+
var lex = db.SortedSetRangeByValue(key, default, "c");
193+
CollectionAssert.AreEqual(new RedisValue[] { "a", "b", "c" }, lex);
194+
192195
// XX - Only update elements that already exist. Don't add new elements.
193196
var testEntries = new[]
194197
{
@@ -200,6 +203,8 @@ public void AddWithOptions()
200203

201204
added = db.SortedSetAdd(key, testEntries, SortedSetWhen.Exists);
202205
ClassicAssert.AreEqual(0, added);
206+
lex = db.SortedSetRangeByValue(key, default, "c");
207+
CollectionAssert.AreEqual(new RedisValue[] { "a", "c", "b" }, lex);
203208
var scores = db.SortedSetScores(key, [new RedisValue("a"), new RedisValue("b")]);
204209
CollectionAssert.AreEqual(new double[] { 3, 4 }, scores);
205210
var count = db.SortedSetLength(key);
@@ -216,6 +221,8 @@ public void AddWithOptions()
216221

217222
added = db.SortedSetAdd(key, testEntries, SortedSetWhen.NotExists);
218223
ClassicAssert.AreEqual(2, added);
224+
lex = db.SortedSetRangeByValue(key, default, "c");
225+
CollectionAssert.AreEqual(new RedisValue[] { "a", "c", "b" }, lex);
219226
scores = db.SortedSetScores(key, [new RedisValue("a"), new RedisValue("b"), new RedisValue("k"), new RedisValue("l")]);
220227
CollectionAssert.AreEqual(new double[] { 3, 4, 11, 12 }, scores);
221228
count = db.SortedSetLength(key);
@@ -231,6 +238,8 @@ public void AddWithOptions()
231238

232239
added = db.SortedSetAdd(key, testEntries, SortedSetWhen.LessThan);
233240
ClassicAssert.AreEqual(1, added);
241+
lex = db.SortedSetRangeByValue(key, default, "c");
242+
CollectionAssert.AreEqual(new RedisValue[] { "a", "b", "c" }, lex);
234243
scores = db.SortedSetScores(key, [new RedisValue("a"), new RedisValue("b"), new RedisValue("m")]);
235244
CollectionAssert.AreEqual(new double[] { 3, 3, 13 }, scores);
236245
count = db.SortedSetLength(key);
@@ -246,6 +255,8 @@ public void AddWithOptions()
246255

247256
added = db.SortedSetAdd(key, testEntries, SortedSetWhen.GreaterThan);
248257
ClassicAssert.AreEqual(1, added);
258+
lex = db.SortedSetRangeByValue(key, default, "c");
259+
CollectionAssert.AreEqual(new RedisValue[] { "b", "c", "a" }, lex);
249260
scores = db.SortedSetScores(key, [new RedisValue("a"), new RedisValue("b"), new RedisValue("n")]);
250261
CollectionAssert.AreEqual(new double[] { 4, 3, 14 }, scores);
251262
count = db.SortedSetLength(key);
@@ -2044,6 +2055,12 @@ public void CanDoZRangeByLex()
20442055
expectedResponse = "*3\r\n$1\r\na\r\n$1\r\nb\r\n$1\r\nc\r\n";
20452056
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
20462057
ClassicAssert.AreEqual(expectedResponse, actualValue);
2058+
2059+
// ZRANGEBYLEX Synonym
2060+
response = lightClientRequest.SendCommand("ZRANGEBYLEX board - [c", 4);
2061+
//expectedResponse = "*3\r\n$1\r\na\r\n$1\r\nb\r\n$1\r\nc\r\n";
2062+
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
2063+
ClassicAssert.AreEqual(expectedResponse, actualValue);
20472064
}
20482065

20492066
[Test]
@@ -2082,6 +2099,12 @@ public void CanDoZRangeByLexReverse()
20822099
expectedResponse = "*3\r\n$1\r\nc\r\n$1\r\nb\r\n$1\r\na\r\n";
20832100
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
20842101
ClassicAssert.AreEqual(expectedResponse, actualValue);
2102+
2103+
// ZREVRANGEBYLEX Synonym
2104+
response = lightClientRequest.SendCommand("ZREVRANGEBYLEX board [c - REV", 4);
2105+
//expectedResponse = "*3\r\n$1\r\nc\r\n$1\r\nb\r\n$1\r\na\r\n";
2106+
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
2107+
ClassicAssert.AreEqual(expectedResponse, actualValue);
20852108
}
20862109

20872110
[Test]
@@ -2098,6 +2121,12 @@ public void CanDoZRangeByLexWithLimit()
20982121
expectedResponse = "*3\r\n$7\r\nNewYork\r\n$5\r\nParis\r\n$5\r\nSeoul\r\n";
20992122
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
21002123
ClassicAssert.AreEqual(expectedResponse, actualValue);
2124+
2125+
// ZRANGEBYLEX Synonym
2126+
response = lightClientRequest.SendCommand("ZRANGEBYLEX mycity - + LIMIT 2 3", 4);
2127+
//expectedResponse = "*3\r\n$7\r\nNewYork\r\n$5\r\nParis\r\n$5\r\nSeoul\r\n";
2128+
actualValue = Encoding.ASCII.GetString(response).Substring(0, expectedResponse.Length);
2129+
ClassicAssert.AreEqual(expectedResponse, actualValue);
21012130
}
21022131

21032132

0 commit comments

Comments
 (0)