示例#1
0
        public void Peek_LongString_ReturnsSameAsPop()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

            using (var scanner = new StringStream(input))
            {
                while (!scanner.IsCompleted)
                {
                    char ch = scanner.Peek();
                    Assert.Equal(scanner.Pop(), ch);
                }

                Assert.Equal(true, scanner.IsCompleted);
            }
        }
示例#2
0
        public void Pop_UnicodeString_ReturnsSameSequence()
        {
            const string input = "私が日本語を話すことはありません。";

            using (var scanner = new StringStream(input))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
示例#3
0
        public void Pop_EscapedSequence_ReturnsSameSequence()
        {
            const string input = @"""\\\b\f\n\r\t\u0123\u4567\u89AB\uCDEF\uabcd\uef4A\""""";

            using (var scanner = new StringStream(input))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
示例#4
0
        public void Pop_LongString_ReturnsSameSequence()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

            using (var scanner = new StringStream(input))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
示例#5
0
        public void Pop_EmptyString_ReturnsEmptySequence()
        {
            const string input = "";

            using (var scanner = new StringStream(input))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
示例#6
0
        public void Column_MultilineString_CountsCorrectNumberOfColumns()
        {
            const string input = @"Line one
Line two
Line three
Line Four";

            using (var scanner = new StringStream(input))
            {
                while (!scanner.IsCompleted)
                {
                    scanner.Pop();
                }

                Assert.Equal(9, scanner.Column);
            }
        }
示例#7
0
        public void Index_MultilineString_CountsCorrectNumberOfChars()
        {
            const string input = @"Line one
Line two
Line three
Line Four";

            using (var scanner = new StringStream(input))
            {
                long i;
                for (i = 0; !scanner.IsCompleted; i++)
                {
                    scanner.Pop();
                    Assert.Equal(i, scanner.Index);
                }

                Assert.Equal(i - 1, scanner.Index);
            }
        }