コード例 #1
0
ファイル: EsfParserTests.cs プロジェクト: lwes/lwes-dotnet
        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();
            }
        }
コード例 #2
0
ファイル: EsfParserTests.cs プロジェクト: lwes/lwes-dotnet
        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");
        }