Пример #1
0
        public void input_that_repeats_less_than_parsers_lower_bound_fails()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!");
            IParser subject = new Repetition(term, 4, 5);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.False);
        }
Пример #2
0
        public void input_that_repeats_more_than_parsers_upper_bound_passes_and_captures_only_expected_max_range()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!op!op!op!op!op!op!");
            IParser subject = new Repetition(term, 3, 3);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.True);
            Assert.That(result.Value, Is.EqualTo("op!op!op!"));
        }
Пример #3
0
        public void input_that_repeats_exactly_as_many_as_the_upper_bound_passes_and_captures_all_input()
        {
            var term = new LiteralString("op!");
            var scanner = new ScanStrings("op!op!op!");
            IParser subject = new Repetition(term, 1, 3);

            var result = subject.Parse(scanner);

            Assert.That(result.Success, Is.True);
            Assert.That(result.Value, Is.EqualTo("op!op!op!"));
        }