public static void GetHashCodeEqualsTest()
        {
            const string testString     = "test test";
            var          testArray      = testString.ToCharArray();
            var          firstHashCode  = new CharSegment(testArray, 0, 4).GetHashCode();
            var          secondHashCode = new CharSegment(testArray, 5, 4).GetHashCode();

            Assert.Equal(firstHashCode, secondHashCode);
        }
        public static void EqualsTest()
        {
            const string testString = "test test";
            var          testArray  = testString.ToCharArray();
            var          first      = new CharSegment(testArray, 0, 4);
            var          second     = new CharSegment(testArray, 5, 4);

            Assert.True(first.Equals(second));
        }
예제 #3
0
 /// <summary>
 /// Decode hex-encoded <paramref name="inputBuffer"/> and store decoded bytes into <paramref name="outputBuffer"/>.
 /// </summary>
 /// <param name="inputBuffer">Char array contains hex encoded bytes.</param>
 /// <param name="outputBuffer">Byte array to store decoded bytes from <paramref name="inputBuffer"/>. </param>
 /// <param name="inputUsed">Number of bytes read from <paramref name="inputBuffer"/> during decoding.</param>
 /// <param name="outputUsed">Number of bytes written in <paramref name="outputBuffer"/> during decoding.</param>
 /// <returns>Number of bytes decoded into <paramref name="outputBuffer"/>.</returns>
 public static int Decode(CharSegment inputBuffer, ByteSegment outputBuffer, out int inputUsed, out int outputUsed)
 {
     return(DecodeInternal(ref inputBuffer, ref outputBuffer, out inputUsed, out outputUsed));
 }
예제 #4
0
        /// <summary>
        /// Encode <paramref name="inputBuffer"/> bytes and store hex-encoded bytes into <paramref name="outputBuffer"/>.
        /// </summary>
        /// <param name="inputBuffer">Bytes to encode.</param>
        /// <param name="outputBuffer">Char array to store encoded bytes. Minimum length is 4.</param>
        /// <returns>Number of characters encoded into <paramref name="outputBuffer"/>.</returns>
        public static int Encode(ByteSegment inputBuffer, CharSegment outputBuffer)
        {
            int inputUsed, outputUsed;

            return(EncodeInternal(ref inputBuffer, ref outputBuffer, out inputUsed, out outputUsed));
        }