Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jun 11, 2024
1 parent e3a2088 commit e7d6de8
Showing 1 changed file with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void replaceWithOldAndNewValueThrowsIllegalArgumentExceptionIfNewValueIsAMissing
final IllegalArgumentException exception =
assertThrowsExactly(IllegalArgumentException.class, () -> map.replace("key", 1, missingValue));
assertEquals("cannot accept missingValue", exception.getMessage());
assertTrue(map.isEmpty());
}

@Test
Expand All @@ -146,6 +147,7 @@ void replaceThrowsIllegalArgumentExceptionIfNewValueIsAMissingValue()
final IllegalArgumentException exception =
assertThrowsExactly(IllegalArgumentException.class, () -> map.replace("key", missingValue));
assertEquals("cannot accept missingValue", exception.getMessage());
assertTrue(map.isEmpty());
}

@Test
Expand Down Expand Up @@ -185,7 +187,7 @@ void shouldHandleCollisionAndThenLinearProbe()
map.put(key, value);

final int collisionKey = key + map.capacity();
final int collisionValue = collisionKey;
final int collisionValue = collisionKey + 1;
map.put(Integer.valueOf(collisionKey), collisionValue);

assertThat(map.get(key), is(value));
Expand All @@ -206,8 +208,8 @@ void shouldClearCollection()

objectToIntMap.clear();

assertThat(objectToIntMap.size(), is(0));
assertEquals(MISSING_VALUE, objectToIntMap.getValue("1"));
assertTrue(objectToIntMap.isEmpty());
}

@Test
Expand Down Expand Up @@ -514,7 +516,7 @@ void shouldRemoveEntryAndCompactCollisionChain()
objectToIntMap.put(Integer.valueOf(13), 13);

final int collisionKey = key + objectToIntMap.capacity();
final int collisionValue = collisionKey;
final int collisionValue = collisionKey + 1;

objectToIntMap.put(Integer.valueOf(collisionKey), collisionValue);
objectToIntMap.put(Integer.valueOf(14), 14);
Expand Down Expand Up @@ -967,7 +969,6 @@ void getOrDefaultReturnsExistingValue()
map.put(key, value);

assertEquals(value, map.getOrDefault(key, defaultValue));

assertEquals(value, map.getValue(key));
}

Expand All @@ -979,7 +980,6 @@ void getOrDefaultReturnsDefaultValueIfMappingDoesNotExist()
final int defaultValue = 42;

assertEquals(defaultValue, map.getOrDefault(key, defaultValue));

assertEquals(MISSING_VALUE, map.getValue(key));
}

Expand Down Expand Up @@ -1060,12 +1060,13 @@ void mergeReplacesExistingValue()
final int value = 500;
final int newValue = 542;
map.put(key, oldValue);
final IntIntFunction remappingFunction = (v1, v2) ->
{
assertEquals(oldValue, v1);
assertEquals(value, v2);
return v1 + v2;
};
final IntIntFunction remappingFunction =
(v1, v2) ->
{
assertEquals(oldValue, v1);
assertEquals(value, v2);
return v1 + v2;
};

assertEquals(newValue, map.merge(key, value, remappingFunction));

Expand All @@ -1082,12 +1083,13 @@ void mergeDeletesExistingValue()
final int value = 500;
map.put(key, oldValue);
map.put("other", 22);
final IntIntFunction remappingFunction = (v1, v2) ->
{
assertEquals(oldValue, v1);
assertEquals(value, v2);
return missingValue;
};
final IntIntFunction remappingFunction =
(v1, v2) ->
{
assertEquals(oldValue, v1);
assertEquals(value, v2);
return missingValue;
};

assertEquals(missingValue, map.merge(key, value, remappingFunction));

Expand Down

0 comments on commit e7d6de8

Please sign in to comment.