Skip to content

Instantly share code, notes, and snippets.

@borrrden
Created October 14, 2015 06:17
Show Gist options
  • Save borrrden/eb3f275021fe46c7bedc to your computer and use it in GitHub Desktop.
Save borrrden/eb3f275021fe46c7bedc to your computer and use it in GitHub Desktop.
Unit test for issue
void testEnumerator()
{
C4Error err;
char docID[20];
for (int i = 1; i < 100; i++) {
sprintf(docID, "doc-%03d", i);
createRev(c4str(docID), kRevID, kBody);
}
createRev(C4STR("deleteme"), kRevID, kBody);
C4Document *doc = c4doc_get(db, c4str("deleteme"), true, &err);
Assert(doc);
{
TransactionHelper t(db);
int changes = c4doc_insertRevision(doc, C4STR("2-ef10"), kC4SliceNull, true, false, false, &err);
AssertEqual(changes, 1);
c4doc_save(doc, 20u, &err);
}
doc = c4doc_get(db, c4str("deleteme"), true, &err);
Assert(doc->flags & kDeleted);
C4AllDocsOptions options = kC4DefaultAllDocsOptions;
C4DocEnumerator *e = c4db_enumerateAllDocs(db, kC4SliceNull, kC4SliceNull, &options, &err);
while((doc = c4enum_nextDocument(e, NULL)) != NULL) {
Assert(!(doc->docID == c4str("deleteme")));
c4doc_free(doc);
}
c4enum_free(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment