Пример #1
0
 public void Pop_NullString_ReturnsNullChar()
 {
     using (var scanner = new ListStream <char>(null))
     {
         Assert.Equal('\0', scanner.Pop());
     }
 }
Пример #2
0
        public void Pop_NullString_ReturnsEmptySequence()
        {
            using (var scanner = new ListStream <char>(null))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(String.Empty, buffer.ToString());
            }
        }
Пример #3
0
        public void Peek_LongString_ReturnsSameAsPop()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

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

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

            using (var scanner = new ListStream <char>(input.ToCharArray()))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
Пример #5
0
        public void Pop_LongString_ReturnsSameSequence()
        {
            const string input = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

            using (var scanner = new ListStream <char>(input.ToCharArray()))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
Пример #6
0
        public void Pop_EmptyString_ReturnsEmptySequence()
        {
            const string input = "";

            using (var scanner = new ListStream <char>(input.ToCharArray()))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                }

                Assert.Equal(input, buffer.ToString());
            }
        }
Пример #7
0
        public void Pop_EscapedSequence_ReturnsSameSequence()
        {
            const string input = @"""\\\b\f\n\r\t\u0123\u4567\u89AB\uCDEF\uabcd\uef4A\""""";

            using (var scanner = new ListStream <char>(input.ToCharArray()))
            {
                var buffer = new StringBuilder();
                while (!scanner.IsCompleted)
                {
                    buffer.Append(scanner.Pop());
                    scanner.Peek();
                }

                Assert.Equal(input, buffer.ToString());
            }
        }