Пример #1
0
        public void InsertSegmentCollectionThenFindTest()
        {
            SegmentCollection segs1 = new SegmentCollection();
            SegmentCollection segs2 = new SegmentCollection();
            Segment           s1, s2, s3, s4;

            s1 = new Segment(buf1, 0, 5);
            s2 = new Segment(buf2, 6, 8);
            s3 = new Segment(buf2, 0, 5);
            s4 = new Segment(buf1, 6, 8);

            segs1.Append(s1);
            segs1.Append(s2);
            segs2.Append(s3);
            segs2.Append(s4);

            segs1.Insert(segs2, 4);

            long map;

            List <Segment> .Node n;
            //segs1.List.Display();
            Assert.AreSame(s1, segs1.FindSegment(3, out map, out n), "s1");
            Assert.AreEqual(0, map);
            Assert.AreSame(s3, segs1.FindSegment(7, out map, out n), "s3");
            Assert.AreEqual(4, map);
            Assert.AreSame(s4, segs1.FindSegment(12, out map, out n), "s4");
            Assert.AreEqual(10, map);
            Segment s5 = segs1.FindSegment(13, out map, out n);

            Assert.AreEqual(13, map);
            Assert.IsTrue(s5.End == s5.Start + 1, "s1'");
            Assert.AreSame(s2, segs1.FindSegment(15, out map, out n), "s2");
            Assert.AreEqual(15, map);
        }
Пример #2
0
        public void FindSegmentTest()
        {
            SegmentCollection segs1 = new SegmentCollection();
            Segment           s1, s2, s3, s4;

            s1 = new Segment(buf1, 0, 5);
            s2 = new Segment(buf2, 6, 8);
            s3 = new Segment(buf2, 0, 5);
            s4 = new Segment(buf1, 6, 8);
            segs1.Append(s1);
            segs1.Append(s2);
            segs1.Append(s3);
            segs1.Append(s4);

            long map;

            List <Segment> .Node n;

            Assert.AreSame(s1, segs1.FindSegment(4, out map, out n));
            Assert.AreEqual(0, map);
            Assert.AreSame(s3, segs1.FindSegment(10, out map, out n));
            Assert.AreEqual(9, map);
        }
Пример #3
0
        public void InsertToSegmentCollectionThenDeleteTest()
        {
            SegmentCollection segs1 = new SegmentCollection();
            Segment           s1, s2;

            s1 = new Segment(buf1, 0, 2);
            s2 = new Segment(buf1, 3, 5);
            segs1.Append(s1);
            SegmentCollection segs2 = new SegmentCollection();

            segs2.Append(s2);
            segs1.Insert(segs2, 2);

            segs1.DeleteRange(2, 4);

            long map;

            List <Segment> .Node n;
            Segment s = segs1.FindSegment(0, out map, out n);

            Assert.IsNotNull(s, "#1");
            Assert.AreEqual(0, map, "#2");
            Assert.AreEqual(0, s.Start, "#3");
        }