Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToRemovePeekedEntries()
        public virtual void ShouldBeAbleToRemovePeekedEntries()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(OK, queue.Offer(1));
            assertEquals(OK, queue.Offer(2));
            assertEquals(OK, queue.Offer(3));
            assertEquals(3, queue.Count());
            assertEquals(6, queue.Bytes());

            assertTrue(queue.Peek().Present);
            assertTrue(queue.Peek().get().remove());
            assertEquals(2, queue.Count());
            assertEquals(5, queue.Bytes());

            assertTrue(queue.Peek().Present);
            assertTrue(queue.Peek().get().remove());
            assertEquals(1, queue.Count());
            assertEquals(3, queue.Bytes());

            assertTrue(queue.Peek().Present);
            assertTrue(queue.Peek().get().remove());
            assertEquals(0, queue.Count());
            assertEquals(0, queue.Bytes());

            assertFalse(queue.Peek().Present);
            try
            {
                queue.Peek().get().remove();
                fail();
            }
            catch (NoSuchElementException)
            {
            }
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowMinCountDespiteSizeLimit()
        public virtual void ShouldAllowMinCountDespiteSizeLimit()
        {
            Config config = new Config(2, 5, 100);
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(config, int?.longValue, _noPriority);

            assertEquals(OK, queue.Offer(101));
            assertEquals(OK, queue.Offer(101));
            assertEquals(E_SIZE_EXCEEDED, queue.Offer(1));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowMoreThanMaxBytes()
        public virtual void ShouldNotAllowMoreThanMaxBytes()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(E_SIZE_EXCEEDED, queue.Offer(101));
            assertEquals(OK, queue.Offer(99));
            assertEquals(OK, queue.Offer(1));
            assertEquals(E_SIZE_EXCEEDED, queue.Offer(1));
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAllowZeroSizedItemsDespiteSizeLimit()
        public virtual void ShouldAllowZeroSizedItemsDespiteSizeLimit()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(OK, queue.Offer(100));
            assertEquals(E_SIZE_EXCEEDED, queue.Offer(1));

            assertEquals(OK, queue.Offer(0));
            assertEquals(OK, queue.Offer(0));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeAbleToPeekEntries()
        public virtual void ShouldBeAbleToPeekEntries()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(OK, queue.Offer(1));
            assertEquals(OK, queue.Offer(2));
            assertEquals(OK, queue.Offer(3));

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(1, queue.Peek().map(Removable::get));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(1, queue.Peek().map(Removable::get));
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            assertEquals(1, queue.Peek().map(Removable::get));

            assertEquals(3, queue.Count());
            assertEquals(6, queue.Bytes());
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReportTotalCountAndSize()
        public virtual void ShouldReportTotalCountAndSize()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(0, queue.Bytes());
            assertEquals(0, queue.Count());

            queue.Offer(10);
            assertEquals(1, queue.Count());
            assertEquals(10, queue.Bytes());

            queue.Offer(20);
            assertEquals(2, queue.Count());
            assertEquals(30, queue.Bytes());

            queue.Poll();
            assertEquals(1, queue.Count());
            assertEquals(20, queue.Bytes());

            queue.Poll();
            assertEquals(0, queue.Count());
            assertEquals(0, queue.Bytes());
        }
Beispiel #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowMoreThanMaxCountDespiteZeroSize()
        public virtual void ShouldNotAllowMoreThanMaxCountDespiteZeroSize()
        {
            BoundedPriorityQueue <int> queue = new BoundedPriorityQueue <int>(_baseConfig, int?.longValue, _noPriority);

            assertEquals(OK, queue.Offer(0));
            assertEquals(OK, queue.Offer(0));
            assertEquals(OK, queue.Offer(0));
            assertEquals(OK, queue.Offer(0));
            assertEquals(OK, queue.Offer(0));

            assertEquals(E_COUNT_EXCEEDED, queue.Offer(0));
        }