public void Decode_InvalidBytes() { foreach (var objectse in Decode_InvalidBytes_TestData()) { byte[] littleEndianBytes = (byte[])objectse[0]; int index = (int)objectse[1]; int count = (int)objectse[2]; string expected = (string)objectse[3]; 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); } }
public void Decode_InvalidBytes() { foreach (var objectse in ASCIIEncodingDecodeTests.Decode_InvalidBytes_TestData()) { byte[] bytes = objectse[0] as byte[]; int index = (int)objectse[1]; int count = (int)objectse[2]; string expected = GetString(bytes, index, count); EncodingHelpers.Decode(new ASCIIEncoding(), bytes, index, count, expected); } }
public void Decode() { foreach (var objectse in UTF7EncodingDecodeTests.Decode_TestData()) { byte[] bytes = objectse[0] as byte[]; int index = (int)objectse[1]; int count = (int)objectse[2]; string expected = objectse[3] as string; EncodingHelpers.Decode(new UTF7Encoding(true), bytes, index, count, expected); EncodingHelpers.Decode(new UTF7Encoding(false), bytes, index, count, expected); } }
//[Test] //Invalid bytes logic works unstable yet public static void Decode_InvalidBytes() { foreach (var objectse in UTF8EncodingDecodeTests.Decode_InvalidBytes_TestData()) { byte[] bytes = objectse[0] as byte[]; int index = (int)objectse[1]; int count = (int)objectse[2]; string expected = objectse[3] as string; 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() { foreach (var objectse in UTF32EncodingDecodeTests.Decode_TestData()) { byte[] littleEndianBytes = objectse[0] as byte[]; int index = (int)objectse[1]; int count = (int)objectse[2]; string expected = objectse[3] as string; byte[] bigEndianBytes = GetBigEndianBytes(littleEndianBytes, index, count); 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); EncodingHelpers.Decode(new UTF32Encoding(true, true, true), bigEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(true, false, true), bigEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(false, true, true), littleEndianBytes, index, count, expected); EncodingHelpers.Decode(new UTF32Encoding(false, false, true), littleEndianBytes, index, count, expected); } }