Skip to content

Commit

Permalink
Fix quicklist tests for Pop()
Browse files Browse the repository at this point in the history
Now the tests actually compare return values instead of just
verifying _something_ got returned.
  • Loading branch information
mattsta committed Feb 17, 2015
1 parent 395e112 commit 552e590
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/quicklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1757,14 +1757,18 @@ 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;
ql_info(ql);
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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 552e590

Please sign in to comment.