Exemple #1
0
        public void Write_UInt64_Throws_When_Buffer_Is_Too_Small()
        {
            var chars = new char[1];
            var ex    = Assert.Throws <ArgumentException>(() => Hexadecimal.Write(0UL, chars));

            Assert.Equal("output", ex.ParamName);
        }
Exemple #2
0
        public void Write_UInt64(ulong input, LetterCase letterCase, string expected)
        {
            var chars = new char[16];

            Hexadecimal.Write(input, chars, letterCase);
            Assert.Equal(expected, new string(chars));
        }
Exemple #3
0
        public void Write_Byte(byte input, LetterCase letterCase, string expected)
        {
            var chars = new char[2];

            Hexadecimal.Write(input, chars, letterCase);
            Assert.Equal(expected, new string(chars));
        }
Exemple #4
0
        public void Write_Throws_When_Buffer_Is_Too_Small(int byteCount, int charCount, char?separator)
        {
            var chars = new char[charCount];
            var ex    = Assert.Throws <ArgumentException>(() => Hexadecimal.Write(new byte[byteCount], chars, separator));

            Assert.Equal("output", ex.ParamName);
        }
        private static string FormatHexadecimal(ReadOnlyMemory <byte> bytes)
        {
            var charLength = bytes.Length * 2;
            var chars      = charLength <= 64 ? stackalloc char[charLength] : new char[charLength];

            Hexadecimal.Write(bytes.Span, chars);
            return(new string(chars));
        }
Exemple #6
0
        public void Write(byte[] input, LetterCase @case, char?separator, string expected)
        {
            var chars = new char[expected.Length];

            Hexadecimal.Write(input, chars, separator, @case);
            var actual = new string(chars);

            Assert.Equal(expected, actual);
        }