Exemple #1
0
        public void TestRoundTrip(string data)
        {
            var utf8 = System.Text.Encoding.UTF8.GetBytes(data);

            var bytes  = new byte[Base16.GetDecodedFromUtf8Length(utf8.Length)];
            var status = Base16.DecodeFromUtf8(utf8, bytes, out var bytesConsumed, out var bytesWritten);

            Assert.Equal(OperationStatus.Done, status);
            Assert.Equal(utf8.Length, bytesConsumed);
            Assert.Equal(bytes.Length, bytesWritten);

            utf8   = new byte[Base16.GetEncodedToUtf8Length(bytes.Length)];
            status = Base16.EncodeToUtf8(bytes, utf8, out bytesConsumed, out bytesWritten);

            Assert.Equal(OperationStatus.Done, status);
            Assert.Equal(bytes.Length, bytesConsumed);
            Assert.Equal(utf8.Length, bytesWritten);

            Assert.Equal(data.ToUpper(), System.Text.Encoding.UTF8.GetString(utf8));
        }