-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Open
Description
Function quicklistDelEntry() doesn't keep iterator behavior as expected. Here is the code:
TEST("quicklistDelEntry()") {
quicklist *ql = quicklistNew(-2, 1);
quicklistPushTail(ql, "aa", 3);
quicklistPushTail(ql, "bb", 3);
quicklistPushTail(ql, "cc", 3);
quicklistPushTail(ql, "dd", 3);
quicklistPushTail(ql, "ee", 3);
quicklistIter *iter = quicklistGetIteratorAtIdx(ql, AL_START_TAIL, 2);
quicklistEntry entry;
assert(quicklistNext(iter, &entry));
quicklistDelEntry(iter, &entry);
assert(quicklistNext(iter, &entry));
assert(strcmp((char *)entry.value, "bb") == 0);
quicklistReleaseIterator(iter);
quicklistRelease(ql);
}
I think function quicklistGetIteratorAtIdx() should be rewrite to meet the following assertion:
assert((quicklistIter->derection == AL_START_HEAD && quicklistIter->offset >= 0) || (quicklistIter->derection == AL_START_TAIL && quicklistIter->offset < 0))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels