//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() { _set = spy(_set); //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 = DEFAULT_CAPACITY / REMOVALS_RATIO; int removalsToTriggerRehashing = DEFAULT_CAPACITY / REMOVALS_RATIO; for (int i = 0; i < numOfElements; i++) { assertTrue(_set.add(100 + i)); } assertEquals(numOfElements, _set.size()); verify(_set, never()).rehashWithoutGrow(); verify(_set, never()).growAndRehash(); for (int i = 0; i < removalsToTriggerRehashing; i++) { assertTrue(_set.remove(100 + i)); } assertEquals(numOfElements - removalsToTriggerRehashing, _set.size()); verify(_set).rehashWithoutGrow(); verify(_set, never()).growAndRehash(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void addRemoveContains() internal virtual void AddRemoveContains() { _set = spy(_set); assertFalse(_set.contains(0)); assertTrue(_set.add(0)); assertTrue(_set.contains(0)); assertFalse(_set.add(0)); assertEquals(1, _set.size()); assertFalse(_set.contains(1)); assertTrue(_set.add(1)); assertTrue(_set.contains(1)); assertFalse(_set.add(1)); assertEquals(2, _set.size()); assertFalse(_set.contains(2)); assertTrue(_set.add(2)); assertTrue(_set.contains(2)); assertFalse(_set.add(2)); assertEquals(3, _set.size()); assertFalse(_set.contains(3)); assertFalse(_set.remove(3)); assertEquals(3, _set.size()); assertEquals(newSetWith(0, 1, 2), _set); assertTrue(_set.remove(0)); assertFalse(_set.contains(0)); assertEquals(2, _set.size()); assertTrue(_set.remove(1)); assertFalse(_set.contains(1)); assertEquals(1, _set.size()); assertTrue(_set.remove(2)); assertFalse(_set.contains(2)); assertEquals(0, _set.size()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void randomizedTest() internal virtual void RandomizedTest() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int count = 10000 + rnd.nextInt(1000); int count = 10000 + _rnd.Next(1000); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.eclipse.collections.api.set.primitive.MutableLongSet uniqueValues = new org.eclipse.collections.impl.set.mutable.primitive.LongHashSet(); MutableLongSet uniqueValues = new LongHashSet(); while (uniqueValues.size() < count) { uniqueValues.add(_rnd.nextLong()); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long[] values = uniqueValues.toArray(); long[] values = uniqueValues.toArray(); foreach (long v in values) { assertTrue(_set.add(v)); } shuffle(values); foreach (long v in values) { assertTrue(_set.contains(v)); assertFalse(_set.add(v)); } assertTrue(_set.containsAll(values)); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final long[] toRemove = uniqueValues.select(v -> rnd.nextInt(100) < 75).toArray(); long[] toRemove = uniqueValues.select(v => _rnd.Next(100) < 75).toArray(); shuffle(toRemove); foreach (long v in toRemove) { assertTrue(_set.remove(v)); assertFalse(_set.contains(v)); } assertEquals(count - toRemove.Length, _set.size()); }