public void FailedOnNoAddError()
		{
			var parser = new CarGrammar();
			var match = parser.Match("set [throttle] ");
			Assert.IsFalse(match.Success, match.ErrorMessage);
			Assert.AreEqual(2, match.Errors.Count()); // we'll get 'row', and 'until' because 'set' and '[throttle]' matched successfully.
			Assert.AreEqual(0, match.ErrorIndex); // because we didn't set AddError for the un-matched 'at' terminal
			Assert.AreEqual(15, match.ChildErrorIndex); // this is where the actual error was, but we don't know what to expect
		}
		public void FailedOnAddErrorParser()
		{
			var parser = new CarGrammar();
			var match = parser.Match("set ");
			Assert.IsFalse(match.Success, match.ErrorMessage);
			Assert.AreEqual(1, match.Errors.Count()); // telemetry was the error
			Assert.AreEqual(4, match.ErrorIndex);
			CollectionAssert.AreEqual(new string[] { "[brake]", "[throttle]" }, FindPossibilities(match));
		}
Beispiel #3
0
        public void FailedOnNoAddError()
        {
            var parser = new CarGrammar();
            var match  = parser.Match("set [throttle] ");

            Assert.IsFalse(match.Success, match.ErrorMessage);
            Assert.AreEqual(2, match.Errors.Count());         // we'll get 'row', and 'until' because 'set' and '[throttle]' matched successfully.
            Assert.AreEqual(0, match.ErrorIndex);             // because we didn't set AddError for the un-matched 'at' terminal
            Assert.AreEqual(15, match.ChildErrorIndex);       // this is where the actual error was, but we don't know what to expect
        }
Beispiel #4
0
        public void FailedOnAddErrorParser()
        {
            var parser = new CarGrammar();
            var match  = parser.Match("set ");

            Assert.IsFalse(match.Success, match.ErrorMessage);
            Assert.AreEqual(1, match.Errors.Count());             // telemetry was the error
            Assert.AreEqual(4, match.ErrorIndex);
            CollectionAssert.AreEqual(new string[] { "[brake]", "[throttle]" }, FindPossibilities(match));
        }
		public void EmptyInput()
		{
			var parser = new CarGrammar();
			var match = parser.Match("");
			Assert.IsFalse(match.Success, match.ErrorMessage);
			Assert.AreEqual(3, match.Errors.Count()); // row, action(set), action(until)
			CollectionAssert.AreEquivalent(new string[] { "row", "action", "action" }, match.Errors.Select(r => r.Name));
			Assert.AreEqual(0, match.ErrorIndex);
			CollectionAssert.AreEqual(new string[] { "set", "until" }, FindPossibilities(match));
		}
Beispiel #6
0
        public void EmptyInput()
        {
            var parser = new CarGrammar();
            var match  = parser.Match("");

            Assert.IsFalse(match.Success, match.ErrorMessage);
            Assert.AreEqual(3, match.Errors.Count());             // row, action(set), action(until)
            CollectionAssert.AreEquivalent(new string[] { "row", "action", "action" }, match.Errors.Select(r => r.Name));
            Assert.AreEqual(0, match.ErrorIndex);
            CollectionAssert.AreEqual(new string[] { "set", "until" }, FindPossibilities(match));
        }
		public void SuccessMatch()
		{
			var parser = new CarGrammar();

			var match = parser.Match("set [throttle] at 15 %\r\n");
			Assert.IsTrue(match.Success, match.ErrorMessage);
			Assert.AreEqual(3, match.Errors.Count()); // row, action(set), action(until)
			CollectionAssert.AreEquivalent(new string[] { "row", "action", "action" }, match.Errors.Select(r => r.Name));
			Assert.AreEqual(24, match.ErrorIndex);
			CollectionAssert.AreEqual(new string[] { "set", "until" }, FindPossibilities(match));
		}
Beispiel #8
0
        public void SuccessMatch()
        {
            var parser = new CarGrammar();

            var match = parser.Match("set [throttle] at 15 %\r\n");

            Assert.IsTrue(match.Success, match.ErrorMessage);
            Assert.AreEqual(3, match.Errors.Count());             // row, action(set), action(until)
            CollectionAssert.AreEquivalent(new string[] { "row", "action", "action" }, match.Errors.Select(r => r.Name));
            Assert.AreEqual(24, match.ErrorIndex);
            CollectionAssert.AreEqual(new string[] { "set", "until" }, FindPossibilities(match));
        }