Пример #1
0
        public void DoubleIncludeFails()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            Assert.IsFalse(l.TryInclude(0, 1));
        }
Пример #2
0
        public void TwoConnectedIncludesMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            Assert.True(l.TryInclude(1, 1));
            Assert.Equal("0-2", Str(l));
        }
Пример #3
0
        public void TwoDisconnectedIncludesMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            Assert.IsTrue(l.TryInclude(2, 1));
            Assert.AreEqual("0-1;2-3", Str(l));
        }
Пример #4
0
        public void InsertAtBeginingWithMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(4, 2);
            l.TryInclude(8, 2);
            Assert.IsTrue(l.TryInclude(0, 4));
            Assert.AreEqual("0-6;8-10", Str(l));
        }
Пример #5
0
        public void ThreeMergeOverlaping3()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 2);
            l.TryInclude(4, 2);
            Assert.IsFalse(l.TryInclude(1, 4));
            Assert.AreEqual("0-6", Str(l));
        }
Пример #6
0
        public void ThreeIncludesMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            l.TryInclude(2, 1);
            Assert.IsTrue(l.TryInclude(1, 1));
            Assert.AreEqual("0-3", Str(l));
        }
Пример #7
0
 public void CloneIsEqual()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     l.TryInclude(10, 11);
     var l2 = l.Clone();
     Assert.AreEqual("0-1;10-21", Str(l2));
     Assert.AreEqual("0-1;10-21", Str(l));
 }
Пример #8
0
        public void InsertBeforeLastWithMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 2);
            l.TryInclude(8, 2);
            Assert.IsFalse(l.TryInclude(4, 5));
            Assert.AreEqual("0-2;4-10", Str(l));
        }
Пример #9
0
        public void ThreeMergeOverlaping2()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 2);
            l.TryInclude(4, 2);
            Assert.False(l.TryInclude(2, 3));
            Assert.Equal("0-6", Str(l));
        }
Пример #10
0
        public void InsertAtBeginingWithoutMerge()
        {
            var l = new PtrLenList();

            l.TryInclude(4, 2);
            l.TryInclude(8, 2);
            Assert.True(l.TryInclude(0, 2));
            Assert.Equal("0-2;4-6;8-10", Str(l));
        }
Пример #11
0
 public void CloneAndClearWorks()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     l.TryInclude(10, 11);
     var l2 = l.CloneAndClear();
     Assert.AreEqual("0-1;10-21", Str(l2));
     Assert.IsTrue(l.Empty);
 }
Пример #12
0
 public void ALotsOfIncludes2()
 {
     var l = new PtrLenList();
     for (uint i = 0; i < 100; i++)
     {
         Assert.IsTrue(l.TryInclude(i * 4, 2));
     }
     Assert.IsFalse(l.TryInclude(7, 388));
     Assert.AreEqual("0-2;4-6;7-395;396-398", Str(l));
 }
Пример #13
0
        public void CloneIsEqual()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            l.TryInclude(10, 11);
            var l2 = l.Clone();

            Assert.AreEqual("0-1;10-21", Str(l2));
            Assert.AreEqual("0-1;10-21", Str(l));
        }
Пример #14
0
        public void CloneAndClearWorks()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            l.TryInclude(10, 11);
            var l2 = l.CloneAndClear();

            Assert.AreEqual("0-1;10-21", Str(l2));
            Assert.IsTrue(l.Empty);
        }
Пример #15
0
        public void ALotsOfIncludes()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 100; i++)
            {
                Assert.True(l.TryInclude(i * 4, 2));
            }
            Assert.False(l.TryInclude(5, 390));
            Assert.Equal("0-2;4-395;396-398", Str(l));
        }
Пример #16
0
        public void ALotsOfIncludes2()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 100; i++)
            {
                Assert.IsTrue(l.TryInclude(i * 4, 2));
            }
            Assert.IsFalse(l.TryInclude(7, 388));
            Assert.AreEqual("0-2;4-6;7-395;396-398", Str(l));
        }
Пример #17
0
        public void FindFreeSizeAfterWorks()
        {
            var l1 = new PtrLenList();

            l1.TryInclude(0, 2);
            l1.TryInclude(5, 5);
            l1.TryInclude(15, 10);
            Assert.AreEqual(25, l1.FindFreeSizeAfter(1, 6));
            Assert.AreEqual(10, l1.FindFreeSizeAfter(1, 4));
            Assert.AreEqual(2, l1.FindFreeSizeAfter(1, 3));
            Assert.AreEqual(12, l1.FindFreeSizeAfter(12, 1));
        }
Пример #18
0
        public void UnmergeInPlaceWorks()
        {
            var l1 = new PtrLenList();

            l1.TryInclude(0, 2);
            l1.TryInclude(5, 5);
            l1.TryInclude(15, 10);
            var l2 = new PtrLenList();

            l2.TryInclude(6, 3);
            l2.TryInclude(15, 10);
            l1.UnmergeInPlace(l2);
            Assert.AreEqual("0-2;5-6;9-10", Str(l1));
        }
Пример #19
0
 public void AfterClearIsEmpty()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     l.Clear();
     Assert.IsTrue(l.Empty);
 }
Пример #20
0
        public void AfterIncludeIsNonEmpty()
        {
            var l = new PtrLenList();

            Assert.IsTrue(l.TryInclude(0, 1));
            Assert.IsFalse(l.Empty);
        }
Пример #21
0
        public void EmptyIncludeIsNoop()
        {
            var l = new PtrLenList();

            Assert.IsTrue(l.TryInclude(0, 0));
            Assert.IsTrue(l.Empty);
        }
Пример #22
0
        public void ExcludeFromStartOverlap()
        {
            var l = new PtrLenList();

            l.TryInclude(1, 3);
            Assert.IsFalse(l.TryExclude(0, 2));
            Assert.AreEqual("2-4", Str(l));
        }
Пример #23
0
        public void ExcludeFromEnd()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 4);
            Assert.IsTrue(l.TryExclude(2, 2));
            Assert.AreEqual("0-2", Str(l));
        }
Пример #24
0
        public void ExcludeFromEndOverlap()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 3);
            Assert.IsFalse(l.TryExclude(2, 2));
            Assert.AreEqual("0-2", Str(l));
        }
Пример #25
0
        public void ExcludeFromStart()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 4);
            Assert.IsTrue(l.TryExclude(0, 2));
            Assert.AreEqual("2-4", Str(l));
        }
Пример #26
0
        public void EmptyExcludeIsNoop()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 2);
            Assert.IsTrue(l.TryExclude(1, 0));
            Assert.AreEqual("0-2", Str(l));
        }
Пример #27
0
        public void ExcludeSplitRange()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 10);
            Assert.IsTrue(l.TryExclude(3, 2));
            Assert.AreEqual("0-3;5-10", Str(l));
        }
Пример #28
0
        public void AfterClearIsEmpty()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            l.Clear();
            Assert.IsTrue(l.Empty);
        }
Пример #29
0
        public void IncludeAndExcludeMakesEmpty()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 1);
            Assert.IsTrue(l.TryExclude(0, 1));
            Assert.IsTrue(l.Empty);
        }
Пример #30
0
        public void TryFindAndRemovePartRange()
        {
            var l = new PtrLenList();

            l.TryInclude(0, 2);
            l.TryInclude(5, 5);
            l.TryInclude(15, 10);
            ulong pos;

            Assert.IsTrue(l.TryFindLenAndRemove(3, out pos));
            Assert.AreEqual(5ul, pos);
            Assert.AreEqual("0-2;8-10;15-25", Str(l));
            Assert.IsTrue(l.TryFindLenAndRemove(3, out pos));
            Assert.AreEqual(15ul, pos);
            Assert.AreEqual("0-2;8-10;18-25", Str(l));
            Assert.IsTrue(l.TryFindLenAndRemove(1, out pos));
            Assert.AreEqual(0ul, pos);
            Assert.AreEqual("1-2;8-10;18-25", Str(l));
        }
Пример #31
0
        public void SpanExclude()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 10; i++)
            {
                Assert.IsTrue(l.TryInclude(i * 4, 2));
            }
            Assert.IsFalse(l.TryExclude(5, 30));
            Assert.AreEqual("0-2;4-5;36-38", Str(l));
        }
Пример #32
0
        public void SpanExclude4()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 10; i++)
            {
                Assert.IsTrue(l.TryInclude(i * 4, 2));
            }
            Assert.IsFalse(l.TryExclude(16, 17));
            Assert.AreEqual("0-2;4-6;8-10;12-14;33-34;36-38", Str(l));
        }
Пример #33
0
        public void SpanExclude3()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 10; i++)
            {
                Assert.IsTrue(l.TryInclude(i * 4, 2));
            }
            Assert.IsFalse(l.TryExclude(24, 20));
            Assert.AreEqual("0-2;4-6;8-10;12-14;16-18;20-22", Str(l));
        }
Пример #34
0
        public void SpanExclude2()
        {
            var l = new PtrLenList();

            for (uint i = 0; i < 10; i++)
            {
                Assert.True(l.TryInclude(i * 4, 2));
            }
            Assert.False(l.TryExclude(24, 10));
            Assert.Equal("0-2;4-6;8-10;12-14;16-18;20-22;36-38", Str(l));
        }
Пример #35
0
 public void SpanExclude4()
 {
     var l = new PtrLenList();
     for (uint i = 0; i < 10; i++)
     {
         Assert.IsTrue(l.TryInclude(i * 4, 2));
     }
     Assert.IsFalse(l.TryExclude(16, 17));
     Assert.AreEqual("0-2;4-6;8-10;12-14;33-34;36-38", Str(l));
 }
Пример #36
0
 public void SpanExclude3()
 {
     var l = new PtrLenList();
     for (uint i = 0; i < 10; i++)
     {
         Assert.IsTrue(l.TryInclude(i * 4, 2));
     }
     Assert.IsFalse(l.TryExclude(24, 20));
     Assert.AreEqual("0-2;4-6;8-10;12-14;16-18;20-22", Str(l));
 }
Пример #37
0
 public void AfterIncludeIsNonEmpty()
 {
     var l = new PtrLenList();
     Assert.IsTrue(l.TryInclude(0, 1));
     Assert.IsFalse(l.Empty);
 }
Пример #38
0
 public void ExcludeFromEnd()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 4);
     Assert.IsTrue(l.TryExclude(2, 2));
     Assert.AreEqual("0-2", Str(l));
 }
Пример #39
0
 public void TwoDisconnectedIncludesMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.IsTrue(l.TryInclude(2, 1));
     Assert.AreEqual("0-1;2-3", Str(l));
 }
Пример #40
0
 public void TryFindAndRemovePartRange()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     l.TryInclude(5, 5);
     l.TryInclude(15, 10);
     ulong pos;
     Assert.IsTrue(l.TryFindLenAndRemove(3, out pos));
     Assert.AreEqual(5ul, pos);
     Assert.AreEqual("0-2;8-10;15-25", Str(l));
     Assert.IsTrue(l.TryFindLenAndRemove(3, out pos));
     Assert.AreEqual(15ul, pos);
     Assert.AreEqual("0-2;8-10;18-25", Str(l));
     Assert.IsTrue(l.TryFindLenAndRemove(1, out pos));
     Assert.AreEqual(0ul, pos);
     Assert.AreEqual("1-2;8-10;18-25", Str(l));
 }
Пример #41
0
 public void FindFreeSizeAfterWorks()
 {
     var l1 = new PtrLenList();
     l1.TryInclude(0, 2);
     l1.TryInclude(5, 5);
     l1.TryInclude(15, 10);
     Assert.AreEqual(25, l1.FindFreeSizeAfter(1, 6));
     Assert.AreEqual(10, l1.FindFreeSizeAfter(1, 4));
     Assert.AreEqual(2, l1.FindFreeSizeAfter(1, 3));
     Assert.AreEqual(12, l1.FindFreeSizeAfter(12, 1));
 }
Пример #42
0
 public void ExcludeSplitRange()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 10);
     Assert.IsTrue(l.TryExclude(3, 2));
     Assert.AreEqual("0-3;5-10", Str(l));
 }
Пример #43
0
 public void ExcludeFromStartOverlap()
 {
     var l = new PtrLenList();
     l.TryInclude(1, 3);
     Assert.IsFalse(l.TryExclude(0, 2));
     Assert.AreEqual("2-4", Str(l));
 }
Пример #44
0
 public void ExcludeFromStart()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 4);
     Assert.IsTrue(l.TryExclude(0, 2));
     Assert.AreEqual("2-4", Str(l));
 }
Пример #45
0
 public void ExcludeFromEndOverlap()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 3);
     Assert.IsFalse(l.TryExclude(2, 2));
     Assert.AreEqual("0-2", Str(l));
 }
Пример #46
0
 public void ThreeIncludesMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     l.TryInclude(2, 1);
     Assert.IsTrue(l.TryInclude(1, 1));
     Assert.AreEqual("0-3", Str(l));
 }
Пример #47
0
 public void ThreeMergeOverlaping3()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     l.TryInclude(4, 2);
     Assert.IsFalse(l.TryInclude(1, 4));
     Assert.AreEqual("0-6", Str(l));
 }
Пример #48
0
 public void IncludeAndExcludeMakesEmpty()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.IsTrue(l.TryExclude(0, 1));
     Assert.IsTrue(l.Empty);
 }
Пример #49
0
 public void TryFindAndRemoveWholeRange()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     l.TryInclude(5, 5);
     l.TryInclude(15, 10);
     ulong pos;
     Assert.IsFalse(l.TryFindLenAndRemove(15, out pos));
     Assert.AreEqual("0-2;5-10;15-25", Str(l));
     Assert.IsTrue(l.TryFindLenAndRemove(5, out pos));
     Assert.AreEqual(5ul, pos);
     Assert.AreEqual("0-2;15-25", Str(l));
     Assert.IsTrue(l.TryFindLenAndRemove(10, out pos));
     Assert.AreEqual(15ul, pos);
     Assert.AreEqual("0-2", Str(l));
     Assert.IsTrue(l.TryFindLenAndRemove(2, out pos));
     Assert.AreEqual(0ul, pos);
     Assert.AreEqual("", Str(l));
 }
Пример #50
0
 public void InsertAtBeginingWithoutMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(4, 2);
     l.TryInclude(8, 2);
     Assert.IsTrue(l.TryInclude(0, 2));
     Assert.AreEqual("0-2;4-6;8-10", Str(l));
 }
Пример #51
0
 public void UnmergeInPlaceWorks()
 {
     var l1 = new PtrLenList();
     l1.TryInclude(0, 2);
     l1.TryInclude(5, 5);
     l1.TryInclude(15, 10);
     var l2 = new PtrLenList();
     l2.TryInclude(6, 3);
     l2.TryInclude(15, 10);
     l1.UnmergeInPlace(l2);
     Assert.AreEqual("0-2;5-6;9-10", Str(l1));
 }
Пример #52
0
 public void EmptyExcludeIsNoop()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     Assert.IsTrue(l.TryExclude(1, 0));
     Assert.AreEqual("0-2", Str(l));
 }
Пример #53
0
 public void InsertBeforeLastWithMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     l.TryInclude(8, 2);
     Assert.IsFalse(l.TryInclude(4, 5));
     Assert.AreEqual("0-2;4-10", Str(l));
 }
Пример #54
0
 public void EmptyIncludeIsNoop()
 {
     var l = new PtrLenList();
     Assert.IsTrue(l.TryInclude(0, 0));
     Assert.IsTrue(l.Empty);
 }
Пример #55
0
 public void DoubleIncludeFails()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.IsFalse(l.TryInclude(0, 1));
 }
Пример #56
0
 public void SpanExclude()
 {
     var l = new PtrLenList();
     for (uint i = 0; i < 10; i++)
     {
         Assert.IsTrue(l.TryInclude(i * 4, 2));
     }
     Assert.IsFalse(l.TryExclude(5, 30));
     Assert.AreEqual("0-2;4-5;36-38", Str(l));
 }