예제 #1
0
        public void NegativeIndices()
        {
            RangeCollection c = new RangeCollection();

            c.Add(-10);
            c.Add(-5);
            c.Add(5);
            c.Add(-8);
            c.Add(10);
            c.Add(-9);
            c.Add(-11);

            Assert.IsTrue(c.Contains(-10), "#1");
            Assert.IsTrue(c.Contains(-5), "#2");
            Assert.IsTrue(c.Contains(5), "#3");
            Assert.IsTrue(c.Contains(-8), "#4");
            Assert.AreEqual(4, c.RangeCount, "#5");
            Assert.AreEqual(new RangeCollection.Range(-11, -8), c.Ranges[0], "#6");
            Assert.AreEqual(new RangeCollection.Range(-5, -5), c.Ranges[1], "#7");
            Assert.AreEqual(new RangeCollection.Range(5, 5), c.Ranges[2], "#8");
            Assert.AreEqual(new RangeCollection.Range(10, 10), c.Ranges[3], "#9");

            Assert.AreEqual(0, c.FindRangeIndexForValue(-9), "#10");
            Assert.IsTrue(c.FindRangeIndexForValue(-7) < 0, "#11");
        }
예제 #2
0
        public void IPAddressRanges()
        {
            RangeCollection ranges = new RangeCollection();

            int start = GetAddress("127.0.0.1");
            int end   = GetAddress("127.0.0.50");

            for (int i = start; i <= end; i++)
            {
                ranges.Add(i);
            }

            Assert.IsTrue(ranges.Contains(GetAddress("127.0.0.15")));
            Assert.IsFalse(ranges.Contains(GetAddress("127.0.0.0")));
            Assert.IsFalse(ranges.Contains(GetAddress("127.0.0.51")));
        }
예제 #3
0
        public void RemoveMids()
        {
            RangeCollection range = _SetupTestRemoveMerges();

            Assert.AreEqual(5, range.RangeCount);
            Assert.AreEqual(14, range.Ranges[3].Start);
            Assert.AreEqual(15, range.Ranges[3].End);
            Assert.AreEqual(true, range.Contains(9));
            range.Remove(9);
            Assert.AreEqual(false, range.Contains(9));
            Assert.AreEqual(6, range.RangeCount);
            Assert.AreEqual(7, range.Ranges[2].Start);
            Assert.AreEqual(8, range.Ranges[2].End);
            Assert.AreEqual(10, range.Ranges[3].Start);
            Assert.AreEqual(11, range.Ranges[3].End);
            Assert.AreEqual(14, range.Ranges[4].Start);
            Assert.AreEqual(15, range.Ranges[4].End);
        }
예제 #4
0
        public void RemoveEnds()
        {
            RangeCollection range = _SetupTestRemoveMerges();

            Assert.AreEqual(true, range.Contains(5));
            range.Remove(5);
            Assert.AreEqual(false, range.Contains(5));
            Assert.AreEqual(5, range.RangeCount);
            Assert.AreEqual(2, range.Ranges[1].Start);
            Assert.AreEqual(4, range.Ranges[1].End);

            Assert.AreEqual(true, range.Contains(15));
            range.Remove(15);
            Assert.AreEqual(false, range.Contains(15));
            Assert.AreEqual(5, range.RangeCount);
            Assert.AreEqual(14, range.Ranges[3].Start);
            Assert.AreEqual(14, range.Ranges[3].End);
        }
예제 #5
0
        public void ContainsTest()
        {
            RangeCollection c = new RangeCollection();

            c.Add(new AddressRange(1, 100));
            c.Add(new AddressRange(-10, -1));
            for (int i = -15; i < 120; i++)
            {
                bool shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
                Assert.AreEqual(shouldContain, c.Contains(new AddressRange(i, i)), "#1." + i);
            }
        }
예제 #6
0
        private IEnumerable <string> SelectedPeptides(RangeCollection pieceIndexRange, int pieceCount)
        {
            int iPeptide = -1;

            foreach (string peptide in ReactTableUnfiltered.Keys)
            {
                ++iPeptide;
                int pieceIndex = (int)(((long)iPeptide * (long)pieceCount) / (long)ReactTableUnfiltered.Count);
                if (pieceIndexRange.Contains(pieceIndex))
                {
                    yield return(peptide);
                }
            }
        }
예제 #7
0
        public void LargeSequentialContains()
        {
            RangeCollection range = new RangeCollection();
            int             i, n = 1000000;

            for (i = 0; i < n; i++)
            {
                range.Add(i);
            }

            for (i = 0; i < n; i++)
            {
                Assert.AreEqual(true, range.Contains(i));
            }
        }
예제 #8
0
        public void RemoveStarts()
        {
            RangeCollection range = _SetupTestRemoveMerges();

            Assert.AreEqual(true, range.Contains(0));
            range.Remove(0);
            Assert.AreEqual(false, range.Contains(0));
            Assert.AreEqual(4, range.RangeCount);

            Assert.AreEqual(true, range.Contains(2));
            range.Remove(2);
            Assert.AreEqual(false, range.Contains(2));
            Assert.AreEqual(4, range.RangeCount);
            Assert.AreEqual(3, range.Ranges[0].Start);
            Assert.AreEqual(5, range.Ranges[0].End);

            Assert.AreEqual(true, range.Contains(14));
            range.Remove(14);
            Assert.AreEqual(false, range.Contains(14));
            Assert.AreEqual(4, range.RangeCount);
            Assert.AreEqual(15, range.Ranges[2].Start);
            Assert.AreEqual(15, range.Ranges[2].End);
        }
 public void ContainsTest()
 {
     RangeCollection c = new RangeCollection();
     c.Add(new AddressRange(1, 100));
     c.Add(new AddressRange(-10, -1));
     for (int i = -15; i < 120; i++)
     {
         bool shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
         Assert.AreEqual(shouldContain, c.Contains(new AddressRange(i, i)), "#1." + i);
     }
 }
예제 #10
0
        public void LargeSequentialContains ()
        {
            RangeCollection range = new RangeCollection ();
            int i, n = 1000000;

            for (i = 0; i < n; i++) {
                range.Add (i);
            }

            for (i = 0; i < n; i++) {
                Assert.AreEqual (true, range.Contains (i));
            }
        }
예제 #11
0
        public void IPAddressRanges ()
        {
            RangeCollection ranges = new RangeCollection ();

            int start = GetAddress ("127.0.0.1");
            int end = GetAddress ("127.0.0.50");

            for (int i = start; i <= end; i++) {
                ranges.Add (i);
            }

            Assert.IsTrue (ranges.Contains (GetAddress ("127.0.0.15")));
            Assert.IsFalse (ranges.Contains (GetAddress ("127.0.0.0")));
            Assert.IsFalse (ranges.Contains (GetAddress ("127.0.0.51")));
        }
예제 #12
0
        public void NegativeIndices ()
        {
            RangeCollection c = new RangeCollection ();
            c.Add (-10);
            c.Add (-5);
            c.Add (5);
            c.Add (-8);
            c.Add (10);
            c.Add (-9);
            c.Add (-11);

            Assert.IsTrue (c.Contains(-10), "#1");
            Assert.IsTrue (c.Contains(-5), "#2");
            Assert.IsTrue (c.Contains(5), "#3");
            Assert.IsTrue (c.Contains(-8), "#4");
            Assert.AreEqual (4, c.RangeCount, "#5");
            Assert.AreEqual (new RangeCollection.Range (-11, -8), c.Ranges[0], "#6");
            Assert.AreEqual (new RangeCollection.Range (-5, -5), c.Ranges[1], "#7");
            Assert.AreEqual (new RangeCollection.Range (5, 5), c.Ranges[2], "#8");
            Assert.AreEqual (new RangeCollection.Range (10, 10), c.Ranges[3], "#9");

            Assert.AreEqual (0, c.FindRangeIndexForValue (-9), "#10");
            Assert.IsTrue (c.FindRangeIndexForValue (-7) < 0, "#11");
        }
 public void ContainsTest()
 {
     var c = new RangeCollection();
     c.Add(new AddressRange(1, 100));
     c.Add(new AddressRange(-10, -1));
     for (var i = -15; i < 120; i++)
     {
         var shouldContain = (i >= -10 && i <= -1) || (i >= 1 && i <= 100);
         Assert.Equal(shouldContain, c.Contains(new AddressRange(i, i)));
     }
 }