コード例 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void rehashWhenTooManyRemovals()
        internal virtual void RehashWhenTooManyRemovals()
        {
            _map = spy(_map);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int numOfElements = DEFAULT_CAPACITY / 2;
            int numOfElements = DEFAULT_CAPACITY / 2;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int removalsToTriggerRehashing = (int)(DEFAULT_CAPACITY * REMOVALS_FACTOR);
            int removalsToTriggerRehashing = ( int )(DEFAULT_CAPACITY * REMOVALS_FACTOR);

            for (int i = 0; i < numOfElements; i++)
            {
                _map.put(100 + i, i);
            }

            assertEquals(numOfElements, _map.size());
            verify(_map, never()).rehashWithoutGrow();
            verify(_map, never()).growAndRehash();

            for (int i = 0; i < removalsToTriggerRehashing; i++)
            {
                _map.remove(100 + i);
            }

            assertEquals(numOfElements - removalsToTriggerRehashing, _map.size());
            verify(_map).rehashWithoutGrow();
            verify(_map, never()).growAndRehash();
        }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void grow()
        internal virtual void Grow()
        {
            _map = spy(_map);

            for (int i = 0; i < DEFAULT_CAPACITY; i++)
            {
                _map.put(100 + i, i);
            }
            verify(_map).growAndRehash();
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void putGetRemove()
        internal virtual void PutGetRemove()
        {
            _map.put(0, 10);
            _map.put(1, 11);
            _map.put(2, 12);

            assertEquals(10, _map.get(0));
            assertEquals(11, _map.get(1));
            assertEquals(12, _map.get(2));
            // default empty value
            assertEquals(0, _map.get(3));

            _map.remove(1);
            _map.remove(2);
            _map.remove(0);

            assertEquals(0, _map.get(0));
            assertEquals(0, _map.get(1));
            assertEquals(0, _map.get(2));
        }