Exemplo n.º 1
0
        public void TestStuff()
        {
            using (SeekableStringReader s = new SeekableStringReader("hello"))
            {
                Assert.AreEqual('h', s.Peek());
                Assert.AreEqual("hel", s.Peek(3));
                Assert.AreEqual('h', s.Read());
                Assert.AreEqual("ell", s.Read(3));
                Assert.AreEqual("o", s.Peek(999));
                Assert.AreEqual("o", s.Read(999));
            }

            using (SeekableStringReader s2 = new SeekableStringReader("    skip.\t\n\rwhitespace.  "))
            {
                s2.SkipWhitespace();
                Assert.AreEqual("skip", s2.ReadUntil('.'));
                s2.SkipWhitespace();
                Assert.AreEqual("whitespace", s2.ReadUntil('.'));
                s2.SkipWhitespace();
                Assert.IsFalse(s2.HasMore());
                Assert.Throws <IndexOutOfRangeException>(() => s2.Peek());
            }
        }