public void GetCharsTest(BaseNEncoding encoding, byte[] plainTextData, string encodedData) { var actual = encoding.GetChars(plainTextData); var charCount = encoding.GetCharCount(plainTextData); Assert.Equal(encodedData, actual); Assert.Equal(charCount, actual.Length); }
public void GetCharCountByteArrayTest() { var base64String = "80_poA1Ahss="; var base64Bytes = new byte[] { 243, 79, 233, 160, 13, 64, 134, 203 }; var baseNEncoding = new BaseNEncoding(BaseNAlphabet.Base64UrlAlphabet, "name"); var actual = baseNEncoding.GetCharCount(base64Bytes, 0, base64Bytes.Length); Assert.Equal(base64String.Length, actual); }
public void GetCharsPartTest(BaseNEncoding encoding, byte[] plainTextData, string encodedData) { var random = new Random(9375220); var input = PadData(plainTextData, out var offset, out var extra, random); var actual = encoding.GetChars(input, offset, plainTextData.Length); var charCount = encoding.GetCharCount(input, offset, plainTextData.Length); Assert.Equal(encodedData, actual); Assert.Equal(charCount, actual.Length); }
public unsafe void GetCharCountPtrTest() { var base64String = "80_poA1Ahss="; var base64Bytes = new byte[] { 243, 79, 233, 160, 13, 64, 134, 203 }; var baseNEncoding = new BaseNEncoding(BaseNAlphabet.Base64UrlAlphabet, "name"); fixed(byte *bytesPtr = base64Bytes) { var actual = baseNEncoding.GetCharCount(bytesPtr, base64Bytes.Length); Assert.Equal(base64String.Length, actual); } }