Пример #1
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));
        }
Пример #2
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));
        }
Пример #3
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));
 }
Пример #4
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));
 }