Exemple #1
0
        public void Unread_Many()
        {
            var text = "abcd";

            using (var textSource = new StringTextSource(text))
            {
                // Arbitrarily chosen array size, but bigger than the input length
                char[] buffer = new char[32];
                int    len    = textSource.Read(buffer, 0, 3);

                Assert.Equal(3, len);
                Assert.Equal('a', buffer[0]);
                Assert.Equal('b', buffer[1]);
                Assert.Equal('c', buffer[2]);
                Assert.Equal(default(char), buffer[3]);

                textSource.Unread(buffer, 0, 3);

                len = textSource.Read(buffer, 0, 4);
                Assert.Equal(4, len);
                Assert.Equal('a', buffer[0]);
                Assert.Equal('b', buffer[1]);
                Assert.Equal('c', buffer[2]);
                Assert.Equal('d', buffer[3]);
            }
        }
Exemple #2
0
        public void Unread_One()
        {
            var text = "abcd";
            using (var textSource = new StringTextSource(text))
            {
                var a = (char)textSource.Read();
                Assert.Equal('a', a);

                textSource.Unread(a);

                a = (char)textSource.Read();
                Assert.Equal('a', a);
            }
        }
Exemple #3
0
        public void Unread_One()
        {
            var text = "abcd";

            using (var textSource = new StringTextSource(text))
            {
                var a = (char)textSource.Read();
                Assert.Equal('a', a);

                textSource.Unread(a);

                a = (char)textSource.Read();
                Assert.Equal('a', a);
            }
        }
Exemple #4
0
        public void Unread_Many()
        {
            var text = "abcd";
            using (var textSource = new StringTextSource(text))
            {
                // Arbitrarily chosen array size, but bigger than the input length
                char[] buffer = new char[32];
                int len = textSource.Read(buffer, 0, 3);

                Assert.Equal(3, len);
                Assert.Equal('a', buffer[0]);
                Assert.Equal('b', buffer[1]);
                Assert.Equal('c', buffer[2]);
                Assert.Equal(default(char), buffer[3]);

                textSource.Unread(buffer, 0, 3);

                len = textSource.Read(buffer, 0, 4);
                Assert.Equal(4, len);
                Assert.Equal('a', buffer[0]);
                Assert.Equal('b', buffer[1]);
                Assert.Equal('c', buffer[2]);
                Assert.Equal('d', buffer[3]);
            }
        }