Ejemplo n.º 1
0
        public void ShouldSplitLettersRangeInputsIntersectsSeveralSegmentsCase()
        {
            TerminalRangeInputCollection <char> items;

            ITerminalRangeInput <char>[] inputs;

            items = new TerminalRangeInputCollection <char>(new FSMLib.LexicalAnalysis.RangeValueProvider());

            Assert.AreEqual(0, items.Count);
            items.Add(new TerminalRangeInput('a', 'c'));
            Assert.AreEqual(1, items.Count);
            items.Add(new TerminalRangeInput('e', 'g'));
            Assert.AreEqual(2, items.Count);
            items.Add(new TerminalRangeInput('c', 'e'));

            inputs = items.ToArray();
            Assert.AreEqual(5, inputs.Length);
            Assert.AreEqual('a', inputs[0].FirstValue);
            Assert.AreEqual('b', inputs[0].LastValue);
            Assert.AreEqual('c', inputs[1].FirstValue);
            Assert.AreEqual('c', inputs[1].LastValue);
            Assert.AreEqual('d', inputs[2].FirstValue);
            Assert.AreEqual('d', inputs[2].LastValue);
            Assert.AreEqual('e', inputs[3].FirstValue);
            Assert.AreEqual('e', inputs[3].LastValue);
            Assert.AreEqual('f', inputs[4].FirstValue);
            Assert.AreEqual('g', inputs[4].LastValue);
        }
Ejemplo n.º 2
0
        public void ShouldEnumerate()
        {
            TerminalRangeInputCollection <char> items;

            ITerminalRangeInput <char>[] ranges;

            items = new TerminalRangeInputCollection <char>(new FSMLib.LexicalAnalysis.RangeValueProvider());

            items.Add('a');
            items.Add('b');

            ranges = items.ToArray();
            Assert.AreEqual(2, ranges.Length);
            Assert.AreEqual('a', ranges[0].FirstValue);
            Assert.AreEqual('a', ranges[0].LastValue);
            Assert.AreEqual('b', ranges[1].FirstValue);
            Assert.AreEqual('b', ranges[1].LastValue);
        }
Ejemplo n.º 3
0
        public void ShouldSplitLettersRangeInputsUsingSingleTerminalCase()
        {
            TerminalRangeInputCollection <char> items;

            ITerminalRangeInput <char>[] inputs;

            items = new TerminalRangeInputCollection <char>(new FSMLib.LexicalAnalysis.RangeValueProvider());

            Assert.AreEqual(0, items.Count);
            items.Add(new TerminalRangeInput('a', 'g'));
            items.Add('c');

            inputs = items.ToArray();
            Assert.AreEqual(3, inputs.Length);
            Assert.AreEqual('a', inputs[0].FirstValue);
            Assert.AreEqual('b', inputs[0].LastValue);
            Assert.AreEqual('c', inputs[1].FirstValue);
            Assert.AreEqual('c', inputs[1].LastValue);
            Assert.AreEqual('d', inputs[2].FirstValue);
            Assert.AreEqual('g', inputs[2].LastValue);
        }