예제 #1
0
        T Peak <T>(SpesificByteParser <T> parser)
        {
            if (!parser.TryDecodeValue(_buffer, _currentIndex, out T value, out int bytesRead, out string error))
            {
                throw new Exception("Unable to parse :" + error);
            }

            return(value);
        }
예제 #2
0
        public void Compare <T>(SpesificByteParser <T> parser, T value)
        {
            var bytesFromValue = parser.EncodeValue(value, out _);

            parser.TryDecode(bytesFromValue, 0, out var stringValue, out _, out _);

            var encodedFromString = parser.Encode(stringValue, out _);

            parser.TryDecode(bytesFromValue, 0, out var stringValue2, out _, out _);

            CompareBytes(bytesFromValue, encodedFromString);

            Assert.NotNull(stringValue);
            Assert.AreEqual(stringValue, stringValue2);
        }