Пример #1
0
        public void ByteStream_IsAnsiLetterTest() {
            byte[] text = new byte[256];
            int i;

            for (i = 0; i < text.Length; i++)
                text[i] = (byte)i;

            ByteStream target = new ByteStream(text);

            for (i = 0; i < 'A'; i++) {
                target.IsAnsiLetter().Should().BeFalse();
                target.MoveToNextChar();
            }

            for (; i <= 'z'; i++) {
                target.IsAnsiLetter().Should().BeTrue();
                target.MoveToNextChar();
            }

            for (; i < text.Length; i++) {
                target.IsAnsiLetter().Should().BeFalse();
                target.MoveToNextChar();
            }

            target.IsAnsiLetter().Should().BeFalse();
        }
Пример #2
0
        public void ByteStream_IsWhiteSpaceTest() {
            byte[] text = new byte[] { (byte)'a', (byte)'\r', (byte)'\n', (byte)'\t', (byte)' ', };
            ByteStream target = new ByteStream(text);

            target.IsWhiteSpace().Should().BeFalse();
            target.MoveToNextChar();
            target.IsWhiteSpace().Should().BeTrue();
            target.MoveToNextChar();
            target.IsWhiteSpace().Should().BeTrue();
            target.MoveToNextChar();
            target.IsWhiteSpace().Should().BeTrue();
            target.MoveToNextChar();
            target.IsWhiteSpace().Should().BeTrue();
        }
Пример #3
0
        public void ByteStream_NextCharTest() {
            byte[] text = { (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            for (int i = 0; i < text.Length - 1; i++) {
                target.NextChar.Should().Be(text[i + 1]);
                target.MoveToNextChar();
            }

            target.NextChar.Should().Be(0);
        }
Пример #4
0
        public void ByteStream_IsNewLineCharTest() {
            byte[] text = new byte[] { (byte)'a', (byte)'\r', (byte)'\n', (byte)'d', (byte)'e', };
            ByteStream target = new ByteStream(text);

            target.IsNewLineChar().Should().BeFalse();
            target.MoveToNextChar();
            target.IsNewLineChar().Should().BeTrue();
            target.MoveToNextChar();
            target.IsNewLineChar().Should().BeTrue();
            target.MoveToNextChar();
            target.IsNewLineChar().Should().BeFalse();
            target.MoveToNextChar();
            target.IsNewLineChar().Should().BeFalse();
        }