Exemplo n.º 1
0
 public void Index_StartState_ReturnsNegOne()
 {
     using (var scanner = new TextReaderStream(TextReader.Null))
     {
         Assert.Equal(-1, scanner.Index);
     }
 }
Exemplo n.º 2
0
 public void Column_StartState_ReturnsNegOne()
 {
     using (var scanner = new TextReaderStream(TextReader.Null))
     {
         Assert.Equal(0, scanner.Column);
     }
 }
Exemplo n.º 3
0
 public void IsCompleted_NullReader_ReturnsFalse()
 {
     using (var scanner = new TextReaderStream(TextReader.Null))
     {
         Assert.Equal(true, scanner.IsCompleted);
     }
 }
Exemplo n.º 4
0
 public void Pop_NullReader_ReturnsNullChar()
 {
     using (var scanner = new TextReaderStream(TextReader.Null))
     {
         Assert.Equal('\0', scanner.Pop());
     }
 }
Exemplo n.º 5
0
        public void Pop_NullReader_ReturnsEmptySequence()
        {
            using (var scanner = new TextReaderStream(TextReader.Null))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(String.Empty, buffer.ToString());
            }
        }
Exemplo n.º 6
0
        public void Peek_LongString_ReturnsSameAsPop()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

                Assert.Equal(true, scanner.IsCompleted);
            }
        }
Exemplo n.º 7
0
        public void Pop_UnicodeSequence_ReturnsSameSequence()
        {
            const string input = "私が日本語を話すことはありません。";

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

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

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

                Assert.Equal(input, buffer.ToString());
            }
        }
Exemplo n.º 9
0
        public void Pop_LongSequence_ReturnsSameSequence()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

                Assert.Equal(input, buffer.ToString());
            }
        }
Exemplo n.º 10
0
        public void Column_MultilineString_CountsCorrectNumberOfColumns()
        {
            const string input = @"Line one
Line two
Line three
Line Four";

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

                Assert.Equal(9, scanner.Column);
            }
        }
Exemplo n.º 11
0
        public void Index_MultilineString_CountsCorrectNumberOfChars()
        {
            const string input = @"Line one
Line two
Line three
Line Four";

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

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