public static void Decode_InvalidBytes(byte[] bytes, int index, int count, string expected) { EncodingHelpers.Decode(new UTF8Encoding(true, false), bytes, index, count, expected); EncodingHelpers.Decode(new UTF8Encoding(false, false), bytes, index, count, expected); NegativeEncodingTests.Decode_Invalid(new UTF8Encoding(false, true), bytes, index, count); NegativeEncodingTests.Decode_Invalid(new UTF8Encoding(true, true), bytes, index, count); }
public void Decode_InvalidBytes(byte[] bytes, int index, int count) { string expected = GetString(bytes, index, count); EncodingHelpers.Decode(new ASCIIEncoding(), bytes, index, count, expected); // Decoding invalid bytes should throw with a DecoderExceptionFallback Encoding exceptionEncoding = Encoding.GetEncoding("ascii", new EncoderReplacementFallback("?"), new DecoderExceptionFallback()); NegativeEncodingTests.Decode_Invalid(exceptionEncoding, bytes, index, count); }
public void Decode_InvalidBytes(byte[] littleEndianBytes, int index, int count, string expected) { byte[] bigEndianBytes = GetBigEndianBytes(littleEndianBytes); EncodingHelpers.Decode(new UTF32Encoding(true, true, false), bigEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(true, false, false), bigEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(false, true, false), littleEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(false, false, false), littleEndianBytes, index, count, expected); NegativeEncodingTests.Decode_Invalid(new UTF32Encoding(true, true, true), bigEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UTF32Encoding(true, false, true), bigEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UTF32Encoding(false, true, true), littleEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UTF32Encoding(false, false, true), littleEndianBytes, index, count); }
public void Decode_InvalidBytes(byte[] littleEndianBytes, int index, int count, string expected) { byte[] bigEndianBytes = GetBigEndianBytes(littleEndianBytes, index, count); EncodingHelpers.Decode(new UnicodeEncoding(false, true, false), littleEndianBytes, index, count, expected); EncodingHelpers.Decode(new UnicodeEncoding(false, false, false), littleEndianBytes, index, count, expected); EncodingHelpers.Decode(new UnicodeEncoding(true, false, false), bigEndianBytes, index, count, expected); EncodingHelpers.Decode(new UnicodeEncoding(true, true, false), bigEndianBytes, index, count, expected); // Decoding invalid bytes should throw with a DecoderExceptionFallback NegativeEncodingTests.Decode_Invalid(new UnicodeEncoding(false, true, true), littleEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UnicodeEncoding(false, false, true), littleEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UnicodeEncoding(true, false, true), bigEndianBytes, index, count); NegativeEncodingTests.Decode_Invalid(new UnicodeEncoding(true, true, true), bigEndianBytes, index, count); }