}
public void testDescend() {
List<EditRec> edits;
ArrayList<TokenRec> tokenRecs = new ArrayList<TokenRec>();
TokenTable root = new MemoryTokenTable(ArrayBytes.EMPTY_BYTES, tokenRecs);
edits = new ArrayList<EditRec>();
edits.add(new EditRec(1, bytes("a"), false));
edits.add(new EditRec(1, bytes("brother:yes"), false));
edits.add(new EditRec(1, bytes("name:phil"), false));
root=BlueSteelBagIndex.applyEditsToTokenTable(edits, root, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 2); // "2" here means we get three tiers
SlicedBytes sb;
TokenRec tr;
sb = new SlicedBytes(ArrayBytes.fromString("brot"), 0, 4);
tr = root.descend(sb);
assertEquals(3, sb.getSlicePosition());
assertEquals('o', (char)tr.token);
sb = new SlicedBytes(ArrayBytes.fromString("bro"), 0, 3);
tr = root.descend(sb);
assertEquals(3, sb.getSlicePosition());
assertEquals('o', (char)tr.token);
assertEquals(0, sb.getLength());
sb = new SlicedBytes(ArrayBytes.fromString(""), 0, 0);
tr = root.descend(sb);
assertNull(tr);
assertEquals(0, sb.getLength());
sb = new SlicedBytes(ArrayBytes.fromString("a"), 0, 1);
tr = root.descend(sb);
assertEquals(1, sb.getSlicePosition());
assertEquals('a', (char)tr.token);
assertEquals(0, sb.getLength());
sb = new SlicedBytes(ArrayBytes.fromString("brXX"), 0, 4);
tr = root.descend(sb);
assertNull(tr);
assertTrue(sb.getLength() > 0);
sb = new SlicedBytes(ArrayBytes.fromString("aXXX"), 0, 4);
tr = root.descend(sb);
assertNull(tr);
assertTrue(sb.getLength() > 0);
sb = new SlicedBytes(ArrayBytes.fromString("XXXX"), 0, 4);
tr = root.descend(sb);
assertNull(tr);
assertTrue(sb.getLength() > 0);
}