Example #1
0
        public void PeekExpectChar_SuccessCase()
        {
            char[] input = "this is the input".ToCharArray();

            Cursor c = new Cursor();
            for (int i = 0; i < input.Length; i++)
            {
                Assert.AreEqual(i, c);
                Assert.AreEqual(input[i],
                    EsfParser.PeekExpectChar(input, c, input[i]));
                c = c.Increment();
            }
        }
Example #2
0
        public void PeekExpectChar_ParseExceptionIsRaisedWhenInputDoesNotMatchExpected()
        {
            char[] input = "xxyy  zz".ToCharArray();

            Cursor c = new Cursor();

            Assert.AreEqual('x', EsfParser.PeekExpectChar(input, c, 'x'));
            c = c.Increment();
            Assert.AreEqual('x', EsfParser.PeekExpectChar(input, c, 'x'));
            c = c.Increment();
            Assert.AreEqual('y', EsfParser.PeekExpectChar(input, c, 'y'));
            c = c.Increment();
            Assert.AreEqual('y', EsfParser.PeekExpectChar(input, c, 'y'));
            c = c.Increment();
            Assert.AreEqual('a', EsfParser.PeekExpectChar(input, c, 'a'));
            Assert.Fail("Should have blew up when expecting an 'a' in position 4");
        }