CharsetEncoderTestpublic class CharsetEncoderTest extends TestCase
Methods Summary |
---|
public void | test_ConstructorLjava_nio_charset_CharsetFF()
// Regression for HARMONY-141
try {
Charset cs = Charset.forName("UTF-8"); //$NON-NLS-1$
new MockCharsetEncoderForHarmony141(cs, 1.1f, 1);
fail("Assert 0: Should throw IllegalArgumentException."); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
// expected
}
try {
Charset cs = Charset.forName("ISO8859-1"); //$NON-NLS-1$
new MockCharsetEncoderForHarmony141(cs, 1.1f, 1,
new byte[] { 0x1a });
fail("Assert 1: Should throw IllegalArgumentException."); //$NON-NLS-1$
} catch (IllegalArgumentException e) {
// expected
}
| public void | test_ConstructorLjava_nio_charset_CharsetNull()
// Regression for HARMONY-491
CharsetEncoder ech = new MockCharsetEncoderForHarmony491(null, 1, 1);
assertNull(ech.charset());
| public void | test_EncodeLjava_nio_CharBuffer()
MockMalfunctionCharset cs = new MockMalfunctionCharset("mock", null);
try {
cs.encode(CharBuffer.wrap("AB"));
fail("should throw CoderMalfunctionError");// NON-NLS-1$
} catch (CoderMalfunctionError e) {
// expected
}
| public void | test_EncodeLjava_nio_CharBufferLjava_nio_ByteBufferB()
CharsetEncoder encoder = Charset.forName("utf-8").newEncoder();
CharBuffer in1 = CharBuffer.wrap("\ud800");
CharBuffer in2 = CharBuffer.wrap("\udc00");
ByteBuffer out = ByteBuffer.allocate(4);
encoder.reset();
CoderResult result = encoder.encode(in1, out, false);
assertEquals(4, out.remaining());
assertTrue(result.isUnderflow());
result = encoder.encode(in2, out, true);
assertEquals(4, out.remaining());
assertTrue(result.isMalformed());
|
|