h.check(true, "position: can't be larger than capacity");
}
}
private void mark(TestHarness h, BufferFactory factory)
{
Buffer buf = null;
// mark at default position
buf = factory.newInstance();
h.check(buf.mark(), buf, "mark: buf.mark()");
checkStatus(h, buf, "mark", 20, 20, true, 10, 10);
buf.position(15);
checkStatus(h, buf, "mark", 20, 20, true, 5, 15);
h.check(buf.reset(), buf, "mark: buf.reset()");
checkStatus(h, buf, "mark", 20, 20, true, 10, 10);
buf.position(16);
checkStatus(h, buf, "mark", 20, 20, true, 4, 16);
buf.reset();
checkStatus(h, buf, "mark", 20, 20, true, 10, 10);
// mark at specified position
buf = factory.newInstance();
buf.position(5);
buf.mark();
checkStatus(h, buf, "mark", 20, 20, true, 15, 5);
buf.position(6);
checkStatus(h, buf, "mark", 20, 20, true, 14, 6);
buf.reset();
checkStatus(h, buf, "mark", 20, 20, true, 15, 5);
buf.position(7);
checkStatus(h, buf, "mark", 20, 20, true, 13, 7);
buf.reset();
checkStatus(h, buf, "mark", 20, 20, true, 15, 5);
// mark should be discarded if new position is smaller than mark
buf = factory.newInstance();
buf.position(5);
buf.mark();
buf.position(4);
try
{
buf.reset();
h.check(false, "mark: mark not invalidated");
}
catch(InvalidMarkException ime)
{
h.check(true, "mark: invalidated mark");