UTF16CharsetDecoderTestpublic class UTF16CharsetDecoderTest extends AbstractCharsetDecoderTestCase
Fields Summary |
---|
boolean | bigEndian |
Methods Summary |
---|
java.nio.ByteBuffer | getExceptionByteArray()
return null;
| java.nio.ByteBuffer | getMalformByteBuffer()
return null;
// FIXME: different here, RI can parse 0xd8d8
// ByteBuffer buffer = ByteBuffer.allocate(100);
// buffer.put((byte) -1);
// buffer.put((byte) -2);
// buffer.put((byte) 0xdc);
// buffer.put((byte) 0xdc);
// buffer.put(unibytes);
// buffer.flip();
// return buffer;
| byte[] | getUnibytes()
// FIXME: different here
// if don't specified BOM
// ICU default is LE
// JDK default is BE
// maybe start with 0xFEFF, which means big endian
// 0xFFFE, which means little endian
if (bigEndian) {
return new byte[] { -1, -2, 32, 0, 98, 0, 117, 0, 102, 0, 102, 0,
101, 0, 114, 0 };
} else {
unibytes = new byte[] { 0, 32, 0, 98, 0, 117, 0, 102, 0, 102, 0,
101, 0, 114 };
return new byte[] { -2, -1, 0, 32, 0, 98, 0, 117, 0, 102, 0, 102,
0, 101, 0, 114 };
}
| java.nio.ByteBuffer | getUnmappedByteBuffer()
return null;
| protected void | setUp()
cs = Charset.forName("utf-16");
unibytes = new byte[] { 32, 0, 98, 0, 117, 0, 102, 0, 102, 0, 101, 0,
114, 0 };
bom = "\ufeff";
// unibytes = new byte[] {-1, -2, 0, 32, 0, 98, 0, 117, 0, 102, 0, 102,
// 0, 101, 0, 114};
super.setUp();
| protected void | tearDown()
super.tearDown();
| public void | testLittleEndian()
bigEndian = false;
implTestDecodeByteBufferCharBufferboolean();
decoder.reset();
implTestDecodeByteBuffer();
bigEndian = true;
| public void | testMultiStepDecode()
if (!cs.name().equals("mock")) {
decoder.onMalformedInput(CodingErrorAction.REPORT);
decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
CharBuffer out = CharBuffer.allocate(10);
assertTrue(decoder.decode(
ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98 }), out,
true).isMalformed());
decoder.flush(out);
decoder.reset();
out.clear();
assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
.wrap(new byte[] { -1, -2, 32, 0 }), out, false));
assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 98 }), out,
true).isMalformed());
decoder.flush(out);
decoder.reset();
out.clear();
assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
.wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
assertFalse(decoder
.decode(ByteBuffer.wrap(new byte[] {}), out, true)
.isMalformed());
decoder.flush(out);
decoder.reset();
out.clear();
assertFalse(decoder.decode(
ByteBuffer.wrap(new byte[] { -1, -2, 32, 0, 98, 0 }), out,
true).isError());
decoder.flush(out);
decoder.reset();
out.clear();
assertSame(CoderResult.UNDERFLOW, decoder.decode(ByteBuffer
.wrap(new byte[] { -1, -2, 32, 0, 98 }), out, false));
assertTrue(decoder.decode(ByteBuffer.wrap(new byte[] { 0 }), out,
true).isMalformed());
}
|
|