public void Ascii85MaxCharCountAndMaxByteCountReturnCorrectishValues() { var random = new Random(10); for (int blockSize = 0; blockSize < 2048; blockSize++) { byte[] block = new byte[blockSize]; for (int iIndex = 0; iIndex < blockSize; iIndex++) { block[iIndex] = (byte)random.Next(256); } string encodedText = Ascii85.GetString(block); Assert.IsNotNull(encodedText); Assert.IsTrue(encodedText.Length <= Ascii85.GetMaxCharCount(blockSize)); Assert.IsTrue(Ascii85.GetMaxByteCount(encodedText.Length) >= blockSize); } }
public void Base16GetCharsAndGetBytesUpTo2048Bytes() { var random = new Random(10); for (int blockSize = 0; blockSize < 2048; blockSize++) { byte[] block = new byte[blockSize]; for (int iIndex = 0; iIndex < blockSize; iIndex++) { block[iIndex] = (byte)random.Next(256); } string encodedText = Codec.GetString(block); Assert.IsNotNull(encodedText); byte[] decodedBytes = Codec.GetBytes(encodedText); CollectionAssert.AreEqual(block, decodedBytes); } }
public void BtoAAbbreviates() { Assert.AreEqual("z", BtoA.GetString(new byte[] { 0, 0, 0, 0 })); Assert.AreEqual("y", BtoA.GetString(new byte[] { 0x20, 0x20, 0x20, 0x20 })); Assert.AreEqual("zy", BtoA.GetString(new byte[] { 0, 0, 0, 0, 0x20, 0x20, 0x20, 0x20 })); }