コード例 #1
0
        public virtual void Unconsume()
        {
            CharacterReader r = new CharacterReader("one");

            NUnit.Framework.Assert.AreEqual('o', r.Consume());
            NUnit.Framework.Assert.AreEqual('n', r.Current());
            r.Unconsume();
            NUnit.Framework.Assert.AreEqual('o', r.Current());
            NUnit.Framework.Assert.AreEqual('o', r.Consume());
            NUnit.Framework.Assert.AreEqual('n', r.Consume());
            NUnit.Framework.Assert.AreEqual('e', r.Consume());
            NUnit.Framework.Assert.IsTrue(r.IsEmpty());
            r.Unconsume();
            NUnit.Framework.Assert.IsFalse(r.IsEmpty());
            NUnit.Framework.Assert.AreEqual('e', r.Current());
            NUnit.Framework.Assert.AreEqual('e', r.Consume());
            NUnit.Framework.Assert.IsTrue(r.IsEmpty());
            NUnit.Framework.Assert.AreEqual(CharacterReader.EOF, r.Consume());
            r.Unconsume();
            NUnit.Framework.Assert.IsTrue(r.IsEmpty());
            NUnit.Framework.Assert.AreEqual(CharacterReader.EOF, r.Current());
        }