summaryrefslogtreecommitdiff
path: root/src/quicklist.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-08-08 14:03:52 +0800
committerGitHub <noreply@github.com>2021-08-08 09:03:52 +0300
commit563ba7a3f0c6592edaeaf34e76e2e9b96de5c7ca (patch)
treee7681615b8a5e9beb3df6b41e5b677aa6be55753 /src/quicklist.c
parent43eb0ce3bf76a5d287b93a767bead9ad6230a1ad (diff)
downloadredis-563ba7a3f0c6592edaeaf34e76e2e9b96de5c7ca.tar.gz
Fix the wrong method used in quicklistTest. (#8951)
The test try to test `insert before 1 element`, but it use quicklist InsertAfter, a copy-paste typo. The commit also add an assert to verify results in some tests to make sure it is as expected.
Diffstat (limited to 'src/quicklist.c')
-rw-r--r--src/quicklist.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/quicklist.c b/src/quicklist.c
index 4874ecc05..5666aab22 100644
--- a/src/quicklist.c
+++ b/src/quicklist.c
@@ -1976,6 +1976,13 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry);
quicklistInsertBefore(ql, &entry, "abc", 4);
ql_verify(ql, 1, 1, 1, 1);
+
+ /* verify results */
+ quicklistIndex(ql, 0, &entry);
+ if (strncmp((char *)entry.value, "abc", 3)) {
+ ERR("Value 0 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
quicklistRelease(ql);
}
@@ -1985,6 +1992,13 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry);
quicklistInsertAfter(ql, &entry, "abc", 4);
ql_verify(ql, 1, 1, 1, 1);
+
+ /* verify results */
+ quicklistIndex(ql, 0, &entry);
+ if (strncmp((char *)entry.value, "abc", 3)) {
+ ERR("Value 0 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
quicklistRelease(ql);
}
@@ -1995,6 +2009,19 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry);
quicklistInsertAfter(ql, &entry, "abc", 4);
ql_verify(ql, 1, 2, 2, 2);
+
+ /* verify results */
+ quicklistIndex(ql, 0, &entry);
+ if (strncmp((char *)entry.value, "hello", 5)) {
+ ERR("Value 0 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
+ quicklistIndex(ql, 1, &entry);
+ if (strncmp((char *)entry.value, "abc", 3)) {
+ ERR("Value 1 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
+
quicklistRelease(ql);
}
@@ -2003,8 +2030,21 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistPushHead(ql, "hello", 6);
quicklistEntry entry;
quicklistIndex(ql, 0, &entry);
- quicklistInsertAfter(ql, &entry, "abc", 4);
+ quicklistInsertBefore(ql, &entry, "abc", 4);
ql_verify(ql, 1, 2, 2, 2);
+
+ /* verify results */
+ quicklistIndex(ql, 0, &entry);
+ if (strncmp((char *)entry.value, "abc", 3)) {
+ ERR("Value 0 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
+ quicklistIndex(ql, 1, &entry);
+ if (strncmp((char *)entry.value, "hello", 5)) {
+ ERR("Value 1 didn't match, instead got: %.*s", entry.sz,
+ entry.value);
+ }
+
quicklistRelease(ql);
}