Beispiel #1
0
 public void TwoConnectedIncludesMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.True(l.TryInclude(1, 1));
     Assert.Equal("0-2", Str(l));
 }
Beispiel #2
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));
 }
Beispiel #3
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);
 }
Beispiel #4
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));
 }
Beispiel #5
0
 public void IncludeAndExcludeMakesEmpty()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.True(l.TryExclude(0, 1));
     Assert.True(l.Empty);
 }
Beispiel #6
0
 public void EmptyExcludeIsNoop()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 2);
     Assert.True(l.TryExclude(1, 0));
     Assert.Equal("0-2", Str(l));
 }
Beispiel #7
0
 public void AfterClearIsEmpty()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     l.Clear();
     Assert.IsTrue(l.Empty);
 }
Beispiel #8
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));
 }
Beispiel #9
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));
 }
Beispiel #10
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));
 }
Beispiel #11
0
 public void AfterIncludeIsNonEmpty()
 {
     var l = new PtrLenList();
     Assert.IsTrue(l.TryInclude(0, 1));
     Assert.IsFalse(l.Empty);
 }
Beispiel #12
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));
 }
Beispiel #13
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));
 }
Beispiel #14
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));
 }
Beispiel #15
0
 public void EmptyIncludeIsNoop()
 {
     var l = new PtrLenList();
     Assert.IsTrue(l.TryInclude(0, 0));
     Assert.IsTrue(l.Empty);
 }
Beispiel #16
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));
 }
Beispiel #17
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));
 }
Beispiel #18
0
 public void ExcludeFromStart()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 4);
     Assert.IsTrue(l.TryExclude(0, 2));
     Assert.AreEqual("2-4", Str(l));
 }
Beispiel #19
0
 public void ExcludeFromEndOverlap()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 3);
     Assert.IsFalse(l.TryExclude(2, 2));
     Assert.AreEqual("0-2", Str(l));
 }
Beispiel #20
0
 public void ExcludeFromEnd()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 4);
     Assert.IsTrue(l.TryExclude(2, 2));
     Assert.AreEqual("0-2", Str(l));
 }
Beispiel #21
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));
 }
Beispiel #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));
 }
Beispiel #23
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));
 }
Beispiel #24
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));
 }
Beispiel #25
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));
 }
Beispiel #26
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));
 }
Beispiel #27
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));
 }
Beispiel #28
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));
 }
Beispiel #29
0
 public void DoubleIncludeFails()
 {
     var l = new PtrLenList();
     l.TryInclude(0, 1);
     Assert.IsFalse(l.TryInclude(0, 1));
 }
Beispiel #30
0
 public void InsertAtBeginingWithMerge()
 {
     var l = new PtrLenList();
     l.TryInclude(4, 2);
     l.TryInclude(8, 2);
     Assert.True(l.TryInclude(0, 4));
     Assert.Equal("0-6;8-10", Str(l));
 }