Ejemplo n.º 1
0
        public void TestSingleElement() /*throws Exception*/
        {
            IntervalSet s         = IntervalSet.Of(99);
            string      expecting = "99";

            Assert.AreEqual(s.ToString(), expecting);
        }
Ejemplo n.º 2
0
        public virtual string ToString(Grammar g)
        {
            if (tokenTypeSet == null)
            {
                return("");
            }
            string r = tokenTypeSet.ToString(g);

            return(r);
        }
Ejemplo n.º 3
0
        public void TestMixedRangesAndElements() /*throws Exception*/
        {
            IntervalSet s = new IntervalSet();

            s.Add(1);
            s.Add('a', 'z');
            s.Add('0', '9');
            string expecting = "{1, 48..57, 97..122}";

            Assert.AreEqual(s.ToString(), expecting);
        }
Ejemplo n.º 4
0
        public void TestIsolatedElements() /*throws Exception*/
        {
            IntervalSet s = new IntervalSet();

            s.Add(1);
            s.Add('z');
            s.Add('\uFFF0');
            string expecting = "{1, 122, 65520}";

            Assert.AreEqual(s.ToString(), expecting);
        }
Ejemplo n.º 5
0
        public void TestMergeWithDoubleOverlap() /*throws Exception*/
        {
            IntervalSet s = IntervalSet.Of(1, 10);

            s.Add(20, 30);
            s.Add(5, 25);   // overlaps two!
            string expecting = "1..30";
            string result    = s.ToString();

            Assert.AreEqual(result, expecting);
        }
Ejemplo n.º 6
0
        public void TestMergeOfRangesAndSingleValuesReverse() /*throws Exception*/
        {
            IntervalSet s = IntervalSet.Of(43, 65534);

            s.Add(42);
            s.Add(0, 41);
            string expecting = "0..65534";
            string result    = s.ToString();

            Assert.AreEqual(result, expecting);
        }
Ejemplo n.º 7
0
        public void TestMergeOfRangesAndSingleValues() /*throws Exception*/
        {
            // {0..41, 42, 43..65534}
            IntervalSet s = IntervalSet.Of(0, 41);

            s.Add(42);
            s.Add(43, 65534);
            string expecting = "0..65534";
            string result    = s.ToString();

            assertEquals(result, expecting);
        }
Ejemplo n.º 8
0
        public void TestMergeWhereAdditionMergesThreeExistingIntervals()
        {
            IntervalSet s = new IntervalSet();

            s.Add(0);
            s.Add(3);
            s.Add(5);
            s.Add(0, 7);
            String expecting = "0..7";
            String result    = s.ToString();

            Assert.AreEqual(expecting, result);
        }
Ejemplo n.º 9
0
        public void TestMergeWhereAdditionMergesTwoExistingIntervals() /*throws Exception*/
        {
            // 42, 10, {0..9, 11..41, 43..65534}
            IntervalSet s = IntervalSet.Of(42);

            s.Add(10);
            s.Add(0, 9);
            s.Add(43, 65534);
            s.Add(11, 41);
            string expecting = "0..65534";
            string result    = s.ToString();

            Assert.AreEqual(result, expecting);
        }
Ejemplo n.º 10
0
 public void TestMixedRangesAndElements()
 {
     IntervalSet s = new IntervalSet();
     s.Add( 1 );
     s.Add( 'a', 'z' );
     s.Add( '0', '9' );
     string expecting = "{1, 48..57, 97..122}";
     Assert.AreEqual( s.ToString(), expecting );
 }
Ejemplo n.º 11
0
 public void TestIsolatedElements()
 {
     IntervalSet s = new IntervalSet();
     s.Add( 1 );
     s.Add( 'z' );
     s.Add( '\uFFF0' );
     string expecting = "{1, 122, 65520}";
     Assert.AreEqual( s.ToString(), expecting );
 }