Ejemplo n.º 1
0
        public void Test_RangeDictionary_Insert_Completly_Overlapping()
        {
            var cola = new ColaRangeDictionary <int, string>();

            cola.Mark(4, 5, "A");
            Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(1));
            Assert.That(cola.Bounds.Begin, Is.EqualTo(4));
            Assert.That(cola.Bounds.End, Is.EqualTo(5));

            // overlaps all the ranges at once
            // 0123456789   0123456789   0123456789
            // ____A_____ + BBBBBBBBBB = BBBBBBBBBB
            cola.Mark(0, 10, "B");
            Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();

            Assert.That(cola.Count, Is.EqualTo(1));
            var runs = cola.ToArray();

            Assert.That(runs.Length, Is.EqualTo(1));
            Assert.That(runs[0].Begin, Is.EqualTo(0));
            Assert.That(runs[0].End, Is.EqualTo(10));
            Assert.That(runs[0].Value, Is.EqualTo("B"));

            Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
            Assert.That(cola.Bounds.End, Is.EqualTo(10));
        }
Ejemplo n.º 2
0
        public void Test_RangeDictionary_Insert_That_Fits_Between_Two_Ranges()
        {
            var cola = new ColaRangeDictionary <int, string>();

            cola.Mark(0, 1, "A");
            cola.Mark(2, 3, "B");
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(2));

            cola.Mark(1, 2, "C");
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(3));

            Console.WriteLine("Result = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);

            var items = cola.ToArray();

            Assert.That(items.Length, Is.EqualTo(3));

            Assert.That(items[0].Begin, Is.EqualTo(0));
            Assert.That(items[0].End, Is.EqualTo(1));
            Assert.That(items[0].Value, Is.EqualTo("A"));

            Assert.That(items[1].Begin, Is.EqualTo(1));
            Assert.That(items[1].End, Is.EqualTo(2));
            Assert.That(items[1].Value, Is.EqualTo("C"));

            Assert.That(items[2].Begin, Is.EqualTo(2));
            Assert.That(items[2].End, Is.EqualTo(3));
            Assert.That(items[2].Value, Is.EqualTo("B"));
        }
		public void Test_RangeDictionary_Insert_Single()
		{
			var cola = new ColaRangeDictionary<int, string>();
			Assert.That(cola.Count, Is.EqualTo(0));

			cola.Mark(0, 1, "A");
			Assert.That(cola.Count, Is.EqualTo(1));

			var items = cola.ToArray();
			Assert.That(items.Length, Is.EqualTo(1));
			Assert.That(items[0].Begin, Is.EqualTo(0));
			Assert.That(items[0].End, Is.EqualTo(1));
			Assert.That(items[0].Value, Is.EqualTo("A"));
		}
Ejemplo n.º 4
0
        public void Test_RangeDictionary_Insert_Single()
        {
            var cola = new ColaRangeDictionary <int, string>();

            Assert.That(cola.Count, Is.EqualTo(0));

            cola.Mark(0, 1, "A");
            Assert.That(cola.Count, Is.EqualTo(1));

            var items = cola.ToArray();

            Assert.That(items.Length, Is.EqualTo(1));
            Assert.That(items[0].Begin, Is.EqualTo(0));
            Assert.That(items[0].End, Is.EqualTo(1));
            Assert.That(items[0].Value, Is.EqualTo("A"));
        }
Ejemplo n.º 5
0
        public void Test_RangeDictionary_Insert_Out_Of_Order_Non_Overlapping()
        {
            var cola = new ColaRangeDictionary <int, string>();

            Assert.That(cola.Count, Is.EqualTo(0));

            cola.Mark(0, 1, "A");
            Console.WriteLine("FIRST  = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(1));

            cola.Mark(4, 5, "B");
            Console.WriteLine("SECOND = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(2));

            cola.Mark(2, 3, "C");
            Console.WriteLine("THIRD  = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();

            Assert.That(cola.Count, Is.EqualTo(3));
            var runs = cola.ToArray();

            Assert.That(runs.Length, Is.EqualTo(3));

            Assert.That(runs[0].Begin, Is.EqualTo(0));
            Assert.That(runs[0].End, Is.EqualTo(1));
            Assert.That(runs[0].Value, Is.EqualTo("A"));

            Assert.That(runs[1].Begin, Is.EqualTo(2));
            Assert.That(runs[1].End, Is.EqualTo(3));
            Assert.That(runs[1].Value, Is.EqualTo("C"));

            Assert.That(runs[2].Begin, Is.EqualTo(4));
            Assert.That(runs[2].End, Is.EqualTo(5));
            Assert.That(runs[2].Value, Is.EqualTo("B"));

            Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
            Assert.That(cola.Bounds.End, Is.EqualTo(5));
        }
		public void Test_RangeDictionary_Insert_In_Order_Non_Overlapping()
		{
			var cola = new ColaRangeDictionary<int, string>();
			Assert.That(cola.Count, Is.EqualTo(0));

			cola.Mark(0, 1, "A");
			Console.WriteLine("FIRST  = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(1));

			cola.Mark(2, 3, "B");
			Console.WriteLine("SECOND = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(2));

			cola.Mark(4, 5, "C");
			Console.WriteLine("THIRD  = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();

			Assert.That(cola.Count, Is.EqualTo(3));
			var runs = cola.ToArray();
			Assert.That(runs.Length, Is.EqualTo(3));

			Assert.That(runs[0].Begin, Is.EqualTo(0));
			Assert.That(runs[0].End, Is.EqualTo(1));
			Assert.That(runs[0].Value, Is.EqualTo("A"));

			Assert.That(runs[1].Begin, Is.EqualTo(2));
			Assert.That(runs[1].End, Is.EqualTo(3));
			Assert.That(runs[1].Value, Is.EqualTo("B"));

			Assert.That(runs[2].Begin, Is.EqualTo(4));
			Assert.That(runs[2].End, Is.EqualTo(5));
			Assert.That(runs[2].Value, Is.EqualTo("C"));

			Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
			Assert.That(cola.Bounds.End, Is.EqualTo(5));
		}
Ejemplo n.º 7
0
        public void Test_RangeDictionary_Insert_Contained()
        {
            var cola = new ColaRangeDictionary <int, string>();

            cola.Mark(0, 10, "A");
            Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(1));
            Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
            Assert.That(cola.Bounds.End, Is.EqualTo(10));

            // overlaps all the ranges at once

            // 0123456789   0123456789   0123456789
            // AAAAAAAAAA + ____B_____ = AAAABAAAAA
            cola.Mark(4, 5, "B");
            Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(3));
            var items = cola.ToArray();

            Assert.That(items.Length, Is.EqualTo(3));

            Assert.That(items[0].Begin, Is.EqualTo(0));
            Assert.That(items[0].End, Is.EqualTo(4));
            Assert.That(items[0].Value, Is.EqualTo("A"));

            Assert.That(items[1].Begin, Is.EqualTo(4));
            Assert.That(items[1].End, Is.EqualTo(5));
            Assert.That(items[1].Value, Is.EqualTo("B"));

            Assert.That(items[2].Begin, Is.EqualTo(5));
            Assert.That(items[2].End, Is.EqualTo(10));
            Assert.That(items[2].Value, Is.EqualTo("A"));

            Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
            Assert.That(cola.Bounds.End, Is.EqualTo(10));
        }
Ejemplo n.º 8
0
        public void Test_RangeDictionary_Insert_That_Join_Two_Ranges()
        {
            var cola = new ColaRangeDictionary <int, string>();

            cola.Mark(0, 1, "A");
            cola.Mark(2, 3, "A");
            Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();
            Assert.That(cola.Count, Is.EqualTo(2));

            // A_A_ + _A__ = AAA_
            cola.Mark(1, 2, "A");
            Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
            Console.WriteLine("Bounds = " + cola.Bounds);
            cola.Debug_Dump();

            Assert.That(cola.Count, Is.EqualTo(1));
            var runs = cola.ToArray();

            Assert.That(runs[0].Begin, Is.EqualTo(0));
            Assert.That(runs[0].End, Is.EqualTo(3));
            Assert.That(runs[0].Value, Is.EqualTo("A"));
        }
		public void Test_RangeDictionary_Insert_That_Join_Two_Ranges()
		{
			var cola = new ColaRangeDictionary<int, string>();
			cola.Mark(0, 1, "A");
			cola.Mark(2, 3, "A");
			Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(2));

			// A_A_ + _A__ = AAA_
			cola.Mark(1, 2, "A");
			Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();

			Assert.That(cola.Count, Is.EqualTo(1));
			var runs = cola.ToArray();
			Assert.That(runs[0].Begin, Is.EqualTo(0));
			Assert.That(runs[0].End, Is.EqualTo(3));
			Assert.That(runs[0].Value, Is.EqualTo("A"));

		}
		public void Test_RangeDictionary_Insert_That_Fits_Between_Two_Ranges()
		{
			var cola = new ColaRangeDictionary<int, string>();
			cola.Mark(0, 1, "A");
			cola.Mark(2, 3, "B");
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(2));

			cola.Mark(1, 2, "C");
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(3));

			Console.WriteLine("Result = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);

			var items = cola.ToArray();
			Assert.That(items.Length, Is.EqualTo(3));

			Assert.That(items[0].Begin, Is.EqualTo(0));
			Assert.That(items[0].End, Is.EqualTo(1));
			Assert.That(items[0].Value, Is.EqualTo("A"));

			Assert.That(items[1].Begin, Is.EqualTo(1));
			Assert.That(items[1].End, Is.EqualTo(2));
			Assert.That(items[1].Value, Is.EqualTo("C"));

			Assert.That(items[2].Begin, Is.EqualTo(2));
			Assert.That(items[2].End, Is.EqualTo(3));
			Assert.That(items[2].Value, Is.EqualTo("B"));

		}
		public void Test_RangeDictionary_Insert_Contained()
		{
			var cola = new ColaRangeDictionary<int, string>();
			cola.Mark(0, 10, "A");
			Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(1));
			Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
			Assert.That(cola.Bounds.End, Is.EqualTo(10));

			// overlaps all the ranges at once

			// 0123456789   0123456789   0123456789
			// AAAAAAAAAA + ____B_____ = AAAABAAAAA
			cola.Mark(4, 5, "B");
			Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(3));
			var items = cola.ToArray();
			Assert.That(items.Length, Is.EqualTo(3));

			Assert.That(items[0].Begin, Is.EqualTo(0));
			Assert.That(items[0].End, Is.EqualTo(4));
			Assert.That(items[0].Value, Is.EqualTo("A"));

			Assert.That(items[1].Begin, Is.EqualTo(4));
			Assert.That(items[1].End, Is.EqualTo(5));
			Assert.That(items[1].Value, Is.EqualTo("B"));

			Assert.That(items[2].Begin, Is.EqualTo(5));
			Assert.That(items[2].End, Is.EqualTo(10));
			Assert.That(items[2].Value, Is.EqualTo("A"));

			Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
			Assert.That(cola.Bounds.End, Is.EqualTo(10));
		}
		public void Test_RangeDictionary_Insert_Completly_Overlapping()
		{
			var cola = new ColaRangeDictionary<int, string>();
			cola.Mark(4, 5, "A");
			Console.WriteLine("BEFORE = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();
			Assert.That(cola.Count, Is.EqualTo(1));
			Assert.That(cola.Bounds.Begin, Is.EqualTo(4));
			Assert.That(cola.Bounds.End, Is.EqualTo(5));

			// overlaps all the ranges at once
			// 0123456789   0123456789   0123456789
			// ____A_____ + BBBBBBBBBB = BBBBBBBBBB
			cola.Mark(0, 10, "B");
			Console.WriteLine("AFTER  = { " + String.Join(", ", cola) + " }");
			Console.WriteLine("Bounds = " + cola.Bounds);
			cola.Debug_Dump();

			Assert.That(cola.Count, Is.EqualTo(1));
			var runs = cola.ToArray();
			Assert.That(runs.Length, Is.EqualTo(1));
			Assert.That(runs[0].Begin, Is.EqualTo(0));
			Assert.That(runs[0].End, Is.EqualTo(10));
			Assert.That(runs[0].Value, Is.EqualTo("B"));

			Assert.That(cola.Bounds.Begin, Is.EqualTo(0));
			Assert.That(cola.Bounds.End, Is.EqualTo(10));
		}