This adds an extra set of numbers, 900..909, whenever we grow.
Inheritance: XCore.SafeQueue
Exemplo n.º 1
0
        public void QueueReentrant()
        {
            SafeQueue queue = new TrickQueue();
            int       count = 0;

            // fill the first 50 of 100 inital slots.
            for (int i = 0; i < 49; i++)
            {
                queue.Add(i);
                count++;
                Assert.AreEqual(count, queue.Count);
            }
            queue.Add(300);             // causes grow, with extra 10 from reentrant simulation.
            Assert.AreEqual(60, queue.Count);
            count += 11;
            for (int i = 0; i < 49; i++)
            {
                int result = (int)queue.Remove();
                count--;
                Assert.AreEqual(i, result);
                Assert.AreEqual(count, queue.Count);
            }
            Assert.AreEqual(300, (int)queue.Remove());
            count--;
            for (int i = 900; i < 910; i++)
            {
                int result = (int)queue.Remove();
                count--;
                Assert.AreEqual(i, result);
                Assert.AreEqual(count, queue.Count);
            }
        }
Exemplo n.º 2
0
		public void QueueReentrant()
		{
			SafeQueue queue = new TrickQueue();
			int count = 0;
			// fill the first 50 of 100 inital slots.
			for (int i = 0; i < 49; i++)
			{
				queue.Add(i);
				count++;
				Assert.AreEqual(count, queue.Count);
			}
			queue.Add(300); // causes grow, with extra 10 from reentrant simulation.
			Assert.AreEqual(60, queue.Count);
			count += 11;
			for (int i = 0; i < 49; i++)
			{
				int result = (int) queue.Remove();
				count--;
				Assert.AreEqual(i, result);
				Assert.AreEqual(count, queue.Count);
			}
			Assert.AreEqual(300, (int)queue.Remove());
			count--;
			for (int i = 900; i < 910; i++)
			{
				int result = (int) queue.Remove();
				count--;
				Assert.AreEqual(i, result);
				Assert.AreEqual(count, queue.Count);
			}
		}