"<x>hello</x><y><yy>blah</yy>yeah</y><z>final</z>", null, null, null,
DocumentSchema.NO_SCHEMA_CONSTRAINTS).document();
int i;
Element root = doc.getDocumentElement();
Node x = root.getFirstChild();
Node z = root.getLastChild();
Node y = z.getPreviousSibling();
for (Node end : new Node[]{z, root, null}) {
i = 0;
for (Node n : DocIterate.deep(doc, z.getFirstChild(), end)) {
assertSame(z.getFirstChild(), n);
i++;
}
assertEquals(1, i);
i = 0;
for (Node n : DocIterate.deep(doc, z, end)) {
assertSame(i == 0 ? z : z.getFirstChild(), n);
i++;
}
assertEquals(2, i);
i = 0;
for (Node n : DocIterate.deep(doc, root, end)) {
switch (i) {
case 0: assertSame(root, n); break;
case 3: assertSame(y, n); break;
case 4: assertSame(y.getFirstChild(), n); break;
case 5: assertSame(y.getFirstChild().getFirstChild(), n); break;
case 6: assertSame(y.getFirstChild().getNextSibling(), n); break;
default: assertNotNull(n); break;
}
i++;
}
assertEquals(end == z ? 7 : 9, i);