public void testUpdateOutput()
{
{
final MyBasicCodec c = new MyBasicCodec();
final TracingBuffer b = new TracingBuffer();
final Format f = new Format("abc");
c.doUpdateOutput(b, f, 10, 20);
assertEquals(b.getLength(), 10);
assertEquals(b.getOffset(), 20);
assertTrue(b.getFormat() == f);
//System.out.println(b.getStringBuffer().toString());
assertEquals(b.getStringBuffer().toString(),
"setFormat(abc)\n" +
"setLength(10)\n" +
"setOffset(20)\n" +
"getLength\n" +
"getOffset\n" +
"getFormat\n");
}
{
final MyBasicCodec c = new MyBasicCodec();
final TracingBuffer b = new TracingBuffer()
{
//@Override
public int getLength()
{
super.getLength();
return 1;
}
};
final TracingFormat f = new TracingFormat("abc");
assertEquals(f.getStringBuffer().toString(), "");
c.doUpdateOutput(b, f, 10, 20);
assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
assertEquals(b.getLength(), 1);
assertEquals(b.getOffset(), 20);
assertTrue(b.getFormat() == f);
//System.out.println(b.getStringBuffer().toString());
assertEquals(b.getStringBuffer().toString(),
"setFormat(abc)\n" +
"setLength(10)\n" +
"setOffset(20)\n" +
"getLength\n" +
"getOffset\n" +
"getFormat\n");
}
{
final MyBasicCodec c = new MyBasicCodec();
final TracingBuffer b = new TracingBuffer();
final TracingFormat f = new TracingFormat(null);
c.doUpdateOutput(b, f, 10, 20);
assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
assertEquals(b.getLength(), 10);
assertEquals(b.getOffset(), 20);
assertTrue(b.getFormat() == f);
//System.out.println(b.getStringBuffer().toString());
assertEquals(b.getStringBuffer().toString(),
"setFormat(null)\n" +
"setLength(10)\n" +
"setOffset(20)\n" +
"getLength\n" +
"getOffset\n" +
"getFormat\n");
assertEquals(f.getStringBuffer().toString(), "getEncoding\n");
f.toString();
assertEquals(f.getStringBuffer().toString(), "getEncoding\ngetEncoding\n");
}
{
final MyBasicCodec c = new MyBasicCodec();
final TracingBuffer b = new TracingBuffer();
final Format f = null;
c.doUpdateOutput(b, f, 0, 0);
assertEquals(b.getLength(), 0);
assertEquals(b.getOffset(), 0);
assertTrue(b.getFormat() == f);
//System.out.println(b.getStringBuffer().toString());
assertEquals(b.getStringBuffer().toString(),
"setFormat(null)\n" +
"setLength(0)\n" +
"setOffset(0)\n" +
"getLength\n" +
"getOffset\n" +