Commit 552e5908 authored by Matt Stancliff's avatar Matt Stancliff
Browse files

Fix quicklist tests for Pop()

Now the tests actually compare return values instead of just
verifying _something_ got returned.
parent 395e1125
......@@ -1757,7 +1757,8 @@ int quicklistTest(int argc, char *argv[]) {
TEST("pop 1 string from 1") {
quicklist *ql = quicklistNew(-2, options[_i]);
quicklistPushHead(ql, genstr("hello", 331), 32);
char *populate = genstr("hello", 331);
quicklistPushHead(ql, populate, 32);
unsigned char *data;
unsigned int sz;
long long lv;
......@@ -1765,6 +1766,9 @@ int quicklistTest(int argc, char *argv[]) {
quicklistPop(ql, QUICKLIST_HEAD, &data, &sz, &lv);
assert(data != NULL);
assert(sz == 32);
if (strcmp(populate, (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value (%s)", sz,
data, populate);
zfree(data);
ql_verify(ql, 0, 0, 0, 0);
quicklistRelease(ql);
......@@ -1797,6 +1801,9 @@ int quicklistTest(int argc, char *argv[]) {
assert(ret == 1);
assert(data != NULL);
assert(sz == 32);
if (strcmp(genstr("hello", 499 - i), (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value (%s)",
sz, data, genstr("hello", 499 - i));
zfree(data);
}
ql_verify(ql, 0, 0, 0, 0);
......@@ -1816,6 +1823,10 @@ int quicklistTest(int argc, char *argv[]) {
assert(ret == 1);
assert(data != NULL);
assert(sz == 32);
if (strcmp(genstr("hello", 499 - i), (char *)data))
ERR("Pop'd value (%.*s) didn't equal original value "
"(%s)",
sz, data, genstr("hello", 499 - i));
zfree(data);
} else {
assert(ret == 0);
......
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