Unverified Commit 563ba7a3 authored by Binbin's avatar Binbin Committed by GitHub
Browse files

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.
parent 43eb0ce3
...@@ -1976,6 +1976,13 @@ int quicklistTest(int argc, char *argv[], int accurate) { ...@@ -1976,6 +1976,13 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry); quicklistIndex(ql, 0, &entry);
quicklistInsertBefore(ql, &entry, "abc", 4); quicklistInsertBefore(ql, &entry, "abc", 4);
ql_verify(ql, 1, 1, 1, 1); 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); quicklistRelease(ql);
} }
...@@ -1985,6 +1992,13 @@ int quicklistTest(int argc, char *argv[], int accurate) { ...@@ -1985,6 +1992,13 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry); quicklistIndex(ql, 0, &entry);
quicklistInsertAfter(ql, &entry, "abc", 4); quicklistInsertAfter(ql, &entry, "abc", 4);
ql_verify(ql, 1, 1, 1, 1); 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); quicklistRelease(ql);
} }
...@@ -1995,6 +2009,19 @@ int quicklistTest(int argc, char *argv[], int accurate) { ...@@ -1995,6 +2009,19 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistIndex(ql, 0, &entry); quicklistIndex(ql, 0, &entry);
quicklistInsertAfter(ql, &entry, "abc", 4); quicklistInsertAfter(ql, &entry, "abc", 4);
ql_verify(ql, 1, 2, 2, 2); 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); quicklistRelease(ql);
} }
...@@ -2003,8 +2030,21 @@ int quicklistTest(int argc, char *argv[], int accurate) { ...@@ -2003,8 +2030,21 @@ int quicklistTest(int argc, char *argv[], int accurate) {
quicklistPushHead(ql, "hello", 6); quicklistPushHead(ql, "hello", 6);
quicklistEntry entry; quicklistEntry entry;
quicklistIndex(ql, 0, &entry); quicklistIndex(ql, 0, &entry);
quicklistInsertAfter(ql, &entry, "abc", 4); quicklistInsertBefore(ql, &entry, "abc", 4);
ql_verify(ql, 1, 2, 2, 2); 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); quicklistRelease(ql);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment