コード例 #1
0
        public void ByteStream_PositionTest()
        {
            byte[]     text   = new byte[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            target.Position.Should().Be(0);

            target.Advance(1);
            target.Position.Should().Be(1);

            target.Advance(100);
            target.Position.Should().Be(5);

            text   = new byte[0];
            target = new ByteStream(text);
            target.Position.Should().Be(0);
        }
コード例 #2
0
        public void ByteStream_DistanceFromEndTest()
        {
            byte[]     text   = { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            target.DistanceFromEnd.Should().Be(5);

            target.Advance(1);
            target.DistanceFromEnd.Should().Be(4);

            target.Advance(100);
            target.DistanceFromEnd.Should().Be(0);

            text   = new byte[0];
            target = new ByteStream(text);
            target.DistanceFromEnd.Should().Be(0);
        }
コード例 #3
0
        public void ByteStream_IsEndOfStreamTest()
        {
            byte[]     text   = new byte[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            target.IsEndOfStream().Should().BeFalse();

            target.Advance(1);
            target.IsEndOfStream().Should().BeFalse();

            target.Advance(100);
            target.IsEndOfStream().Should().BeTrue();

            text   = new byte[0];
            target = new ByteStream(text);
            target.IsEndOfStream().Should().BeTrue();
        }
コード例 #4
0
        public void ByteStream_CurrentCharTest()
        {
            byte[]     text   = new byte[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            target.CurrentChar.Should().Be((byte)'a');

            target.Advance(1);
            target.CurrentChar.Should().Be((byte)'b');

            target.Advance(100);
            target.CurrentChar.Should().Be(0);

            text   = new byte[0];
            target = new ByteStream(text);
            target.CurrentChar.Should().Be(0);
        }
コード例 #5
0
        public void ByteStream_AdvanceTest()
        {
            byte[]     text   = { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);
            var        actual = target.Advance(0);

            actual.Should().BeTrue();
            target.Position.Should().Be(0);

            actual = target.Advance(1);
            actual.Should().BeTrue();
            target.Position.Should().Be(1);

            actual = target.Advance(100);
            actual.Should().BeFalse();
            target.Position.Should().Be(5);
        }