public void Encode_InvalidChars() { foreach (var objectse in ASCIIEncodingEncodeTests.Encode_InvalidChars_TestData()) { string source = objectse[0] as string; int index = (int)objectse[1]; int count = (int)objectse[2]; byte[] expected = GetBytes(source, index, count); EncodingHelpers.Encode(new ASCIIEncoding(), source, index, count, expected); } }
public void Encode() { foreach (var objectse in UTF7EncodingEncodeTests.Encode_Basic_TestData()) { string source = (string)objectse[0]; int index = (int)objectse[1]; int count = (int)objectse[2]; byte[] expected = (byte[])objectse[3]; EncodingHelpers.Encode(new UTF7Encoding(true), source, index, count, expected); EncodingHelpers.Encode(new UTF7Encoding(false), source, index, count, expected); } }
public void EncodeAdvanced() { foreach (var objectse in UTF7EncodingEncodeTests.Encode_Advanced_TestData()) { bool allowOptionals = (bool)objectse[0]; string source = (string)objectse[1]; int index = (int)objectse[2]; int count = (int)objectse[3]; byte[] expected = (byte[])objectse[4]; EncodingHelpers.Encode(new UTF7Encoding(allowOptionals), source, index, count, expected); } }
public void Encode_InvalidChars() { foreach (var objectse in UTF32EncodingEncodeTests.Encode_InvalidChars_TestData()) { string chars = objectse[0] as string; int index = (int)objectse[1]; int count = (int)objectse[2]; byte[] littleEndianExpected = objectse[3] as byte[]; byte[] bigEndianExpected = GetBigEndianBytes(littleEndianExpected); EncodingHelpers.Encode(new UTF32Encoding(true, true, false), chars, index, count, bigEndianExpected); EncodingHelpers.Encode(new UTF32Encoding(true, false, false), chars, index, count, bigEndianExpected); EncodingHelpers.Encode(new UTF32Encoding(false, true, false), chars, index, count, littleEndianExpected); EncodingHelpers.Encode(new UTF32Encoding(false, false, false), chars, index, count, littleEndianExpected); NegativeEncodingTests.Encode_Invalid(new UTF32Encoding(true, true, true), chars, index, count); NegativeEncodingTests.Encode_Invalid(new UTF32Encoding(true, false, true), chars, index, count); NegativeEncodingTests.Encode_Invalid(new UTF32Encoding(false, true, true), chars, index, count); NegativeEncodingTests.Encode_Invalid(new UTF32Encoding(false, false, true), chars, index, count); } }
public void Encode() { foreach (var objectse in UnicodeEncodingEncodeTests.Encode_TestData()) { string source = (string)objectse[0]; int index = (int)objectse[1]; int count = (int)objectse[2]; byte[] expectedLittleEndian = (byte[])objectse[3]; byte[] expectedBigEndian = GetBigEndianBytes(expectedLittleEndian); EncodingHelpers.Encode(new UnicodeEncoding(false, true, false), source, index, count, expectedLittleEndian); EncodingHelpers.Encode(new UnicodeEncoding(false, false, false), source, index, count, expectedLittleEndian); EncodingHelpers.Encode(new UnicodeEncoding(true, true, false), source, index, count, expectedBigEndian); EncodingHelpers.Encode(new UnicodeEncoding(true, false, false), source, index, count, expectedBigEndian); EncodingHelpers.Encode(new UnicodeEncoding(false, true, true), source, index, count, expectedLittleEndian); EncodingHelpers.Encode(new UnicodeEncoding(false, false, true), source, index, count, expectedLittleEndian); EncodingHelpers.Encode(new UnicodeEncoding(true, true, true), source, index, count, expectedBigEndian); EncodingHelpers.Encode(new UnicodeEncoding(true, false, true), source, index, count, expectedBigEndian); } }
public void Encode_InvalidChars() { foreach (var objectse in UTF8EncodingEncodeTests.Encode_InvalidChars_TestData()) { string chars = (string)objectse[0]; int index = (int)objectse[1]; int count = (int)objectse[2]; byte[] expected = (byte[])objectse[3]; EncodingHelpers.Encode( new UTF8Encoding(encoderShouldEmitUTF8Identifier: true, throwOnInvalidBytes: false), chars, index, count, expected); EncodingHelpers.Encode( new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: false), chars, index, count, expected); NegativeEncodingTests.Encode_Invalid( new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true), chars, index, count); NegativeEncodingTests.Encode_Invalid( new UTF8Encoding(encoderShouldEmitUTF8Identifier: true, throwOnInvalidBytes: true), chars, index, count); } }