public void EncodeTextArgumentErrors() { byte[] buffer = new byte[4]; char[] input = new char[4]; Assert.Throws <ArgumentNullException>( () => encoder.GetBytes((char[])null, 0, 1, buffer, 0)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetBytes(input, -1, 1, buffer, 0)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetBytes(input, 0, 5, buffer, 0)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetBytes(input, 3, 2, buffer, 0)); Assert.Throws <ArgumentNullException>( () => encoder.GetBytes(input, 0, 1, null, 0)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetBytes(input, 0, 1, buffer, -1)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetBytes(input, 0, 1, buffer, 5)); Assert.Throws <ArgumentNullException>( () => encoder.GetByteCount((char[])null, 0, 1)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetByteCount(input, -1, 1)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetByteCount(input, 5, 1)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetByteCount(input, 0, -1)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetByteCount(input, 0, 5)); Assert.Throws <ArgumentOutOfRangeException>( () => encoder.GetMaxByteCount(-1)); }
public void CustomEncoderFallback() { string decoded = "€\ud801\udc37"; encoder = new EucJpEncoding( new DecoderExceptionFallback(), new EncoderReplacementFallback("?!")); byte[] expected = { 0x3F, 0x21, 0x3F, 0x21, 0x3F, 0x21 }; Assert.AreEqual(expected, encoder.GetBytes(decoded)); }