public void BytesReaderParse() { ReadOnlySequence <byte> bytes = BufferFactory.Parse("12|3Tr|ue|456Tr|ue7|89False|"); var reader = new BufferReader <byte>(bytes); Assert.True(reader.TryParse(out long l64)); Assert.Equal(123, l64); Assert.True(reader.TryParse(out bool b)); Assert.Equal(true, b); Assert.True(reader.TryParse(out l64)); Assert.Equal(456, l64); Assert.True(reader.TryParse(out b)); Assert.Equal(true, b); Assert.True(reader.TryParse(out l64)); Assert.Equal(789, l64); Assert.True(reader.TryParse(out b)); Assert.Equal(false, b); }
public void BytesReaderParse() { ReadOnlySequence <byte> bytes = BufferFactory.Parse("12|3Tr|ue|456Tr|ue7|89False|"); var reader = BufferReader.Create(bytes); Assert.True(BufferReaderExtensions.TryParse(ref reader, out ulong u64)); Assert.Equal(123ul, u64); Assert.True(BufferReaderExtensions.TryParse(ref reader, out bool b)); Assert.Equal(true, b); Assert.True(BufferReaderExtensions.TryParse(ref reader, out u64)); Assert.Equal(456ul, u64); Assert.True(BufferReaderExtensions.TryParse(ref reader, out b)); Assert.Equal(true, b); Assert.True(BufferReaderExtensions.TryParse(ref reader, out u64)); Assert.Equal(789ul, u64); Assert.True(BufferReaderExtensions.TryParse(ref reader, out b)); Assert.Equal(false, b); }