Program: 160216
Project: 160216
Buggy source:
/** 
 * in DatabaseInternal_Tests.m -(void) test18_FindMissingRevisions
 */
public void test18_FindMissingRevisions() throws CouchbaseLiteException {
  RevisionList revs=new RevisionList();
  assertEquals(0,database.getStore().findMissingRevisions(revs));
  Map<String,Object> prop1=new HashMap<String,Object>();
  prop1.put("String_Node_Str","String_Node_Str");
  prop1.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc1r1=putDoc(prop1);
  Map<String,Object> prop2=new HashMap<String,Object>();
  prop2.put("String_Node_Str","String_Node_Str");
  prop2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc2r1=putDoc(prop2);
  Map<String,Object> prop3=new HashMap<String,Object>();
  prop3.put("String_Node_Str","String_Node_Str");
  prop3.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc3r1=putDoc(prop3);
  Map<String,Object> prop4=new HashMap<String,Object>();
  prop4.put("String_Node_Str","String_Node_Str");
  prop4.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc4r1=putDoc(prop4);
  Map<String,Object> prop5=new HashMap<String,Object>();
  prop5.put("String_Node_Str","String_Node_Str");
  prop5.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc5r1=putDoc(prop5);
  Map<String,Object> prop1r2=new HashMap<String,Object>();
  prop1r2.put("String_Node_Str","String_Node_Str");
  prop1r2.put("String_Node_Str",doc1r1.getRevID());
  prop1r2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc1r2=putDoc(prop1r2);
  Map<String,Object> prop2r2=new HashMap<String,Object>();
  prop2r2.put("String_Node_Str","String_Node_Str");
  prop2r2.put("String_Node_Str",doc2r1.getRevID());
  prop2r2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc2r2=putDoc(prop2r2);
  Map<String,Object> prop1r3=new HashMap<String,Object>();
  prop1r3.put("String_Node_Str","String_Node_Str");
  prop1r3.put("String_Node_Str",doc1r2.getRevID());
  prop1r3.put("String_Node_Str",true);
  RevisionInternal doc1r3=putDoc(prop1r3);
  RevisionInternal revToFind1=new RevisionInternal("String_Node_Str","String_Node_Str",false);
  RevisionInternal revToFind2=new RevisionInternal("String_Node_Str",doc2r2.getRevID(),false);
  RevisionInternal revToFind3=new RevisionInternal("String_Node_Str","String_Node_Str",false);
  revs=new RevisionList();
  revs.add(revToFind1);
  revs.add(revToFind2);
  revs.add(revToFind3);
  assertEquals(1,database.getStore().findMissingRevisions(revs));
  assertEquals(2,revs.size());
  assertTrue(revs.contains(revToFind1));
  assertFalse(revs.contains(revToFind2));
  assertTrue(revs.contains(revToFind3));
  AtomicBoolean haveBodies=new AtomicBoolean();
  List<String> revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,0,haveBodies);
  assertEquals(2,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  assertTrue(revIDs.contains(doc1r1.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,1,haveBodies);
  assertEquals(1,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind3,0,haveBodies);
  assertNull(revIDs);
}

Fixed version (ground truth):
/** 
 * in DatabaseInternal_Tests.m -(void) test18_FindMissingRevisions
 */
public void test18_FindMissingRevisions() throws CouchbaseLiteException {
  RevisionList revs=new RevisionList();
  assertEquals(0,database.getStore().findMissingRevisions(revs));
  Map<String,Object> prop1=new HashMap<String,Object>();
  prop1.put("String_Node_Str","String_Node_Str");
  prop1.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc1r1=putDoc(prop1);
  Map<String,Object> prop2=new HashMap<String,Object>();
  prop2.put("String_Node_Str","String_Node_Str");
  prop2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc2r1=putDoc(prop2);
  Map<String,Object> prop3=new HashMap<String,Object>();
  prop3.put("String_Node_Str","String_Node_Str");
  prop3.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc3r1=putDoc(prop3);
  Map<String,Object> prop4=new HashMap<String,Object>();
  prop4.put("String_Node_Str","String_Node_Str");
  prop4.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc4r1=putDoc(prop4);
  Map<String,Object> prop5=new HashMap<String,Object>();
  prop5.put("String_Node_Str","String_Node_Str");
  prop5.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc5r1=putDoc(prop5);
  Map<String,Object> prop1r2=new HashMap<String,Object>();
  prop1r2.put("String_Node_Str","String_Node_Str");
  prop1r2.put("String_Node_Str",doc1r1.getRevID());
  prop1r2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc1r2=putDoc(prop1r2);
  Map<String,Object> prop2r2=new HashMap<String,Object>();
  prop2r2.put("String_Node_Str","String_Node_Str");
  prop2r2.put("String_Node_Str",doc2r1.getRevID());
  prop2r2.put("String_Node_Str","String_Node_Str");
  RevisionInternal doc2r2=putDoc(prop2r2);
  Map<String,Object> prop1r3=new HashMap<String,Object>();
  prop1r3.put("String_Node_Str","String_Node_Str");
  prop1r3.put("String_Node_Str",doc1r2.getRevID());
  prop1r3.put("String_Node_Str",true);
  RevisionInternal doc1r3=putDoc(prop1r3);
  RevisionInternal revToFind1=new RevisionInternal("String_Node_Str","String_Node_Str",false);
  RevisionInternal revToFind2=new RevisionInternal("String_Node_Str",doc2r2.getRevID(),false);
  RevisionInternal revToFind3=new RevisionInternal("String_Node_Str","String_Node_Str",false);
  revs=new RevisionList();
  revs.add(revToFind1);
  revs.add(revToFind2);
  revs.add(revToFind3);
  assertEquals(1,database.getStore().findMissingRevisions(revs));
  assertEquals(2,revs.size());
  assertTrue(revs.contains(revToFind1));
  assertFalse(revs.contains(revToFind2));
  assertTrue(revs.contains(revToFind3));
  AtomicBoolean haveBodies=new AtomicBoolean();
  List<String> revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,0,haveBodies,false);
  assertEquals(2,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  assertTrue(revIDs.contains(doc1r1.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,1,haveBodies,false);
  assertEquals(1,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind3,0,haveBodies,false);
  assertNull(revIDs);
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,0,haveBodies,true);
  assertEquals(2,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  assertTrue(revIDs.contains(doc1r1.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind1,1,haveBodies,true);
  assertEquals(1,revIDs.size());
  assertTrue(revIDs.contains(doc1r2.getRevID()));
  revIDs=database.getStore().getPossibleAncestorRevisionIDs(revToFind3,0,haveBodies,true);
  assertNull(revIDs);
}