Exemplo n.º 1
0
        public void TestReadUntil()
        {
            SeekableStringReader s = new SeekableStringReader("hello there");

            s.Read();
            Assert.AreEqual("ello", s.ReadUntil(' '));
            Assert.AreEqual('t', s.Peek());
            Assert.Throws <ParseException>(() => s.ReadUntil('x'));

            Assert.AreEqual("there", s.Rest());
            Assert.Throws <ParseException>(() => s.Rest());

            s.Rewind(int.MaxValue);
            Assert.AreEqual("hell", s.ReadUntil('x', 'y', 'z', ' ', 'o'));
            Assert.Throws <ParseException>(() => s.ReadUntil('x', 'y', '@'));
        }
Exemplo n.º 2
0
        public void TestReadWhile()
        {
            SeekableStringReader s = new SeekableStringReader("123.456 foo");

            Assert.AreEqual("123.456", s.ReadWhile('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'));
            Assert.AreEqual("", s.ReadWhile('@'));
            Assert.AreEqual(" ", s.ReadWhile(' '));
            Assert.AreEqual("foo", s.Rest());
        }
Exemplo n.º 3
0
        public void TestReadWhile()
        {
            SeekableStringReader s = new SeekableStringReader("123.456 foo");

            Assert.AreEqual("123.456", s.ReadWhile("0123456789."));
            Assert.AreEqual("", s.ReadWhile("@"));
            Assert.AreEqual(" ", s.ReadWhile(" "));
            Assert.AreEqual("foo", s.Rest());
        }