예제 #1
0
        public void ParseAWorks()
        {
            var parser = new StartsWithChar('A');
            var result = parser.Parse("A");

            Assert.IsTrue(result.Success);
            Assert.AreEqual("A", result.Parsed);
            Assert.AreEqual("", result.Remainder);
        }
예제 #2
0
        public void OneIs1()
        {
            var parser = new StartsWithChar('1').ApplyString(l => int.Parse(l));
            var result = parser.Parse("1");

            Assert.IsTrue(result.Success);
            Assert.AreEqual(1, result.Parsed);
            Assert.AreEqual("", result.Remainder);
        }
예제 #3
0
        public void ParseBADoesNotWork()
        {
            var parser = new StartsWithChar('A');
            var result = parser.Parse("BA");

            Assert.IsFalse(result.Success);
            Assert.IsNull(result.Parsed);
            Assert.AreEqual("BA", result.Remainder);
        }