Polishing

This commit is contained in:
Sam Brannen 2023-11-04 14:45:09 +01:00
parent ed49f86dfb
commit b3a6dbaab3
1 changed files with 10 additions and 12 deletions

View File

@ -37,6 +37,7 @@ import org.springframework.util.comparator.Comparators;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatNoException;
/**
* Tests for {@link ConcurrentReferenceHashMap}.
@ -95,26 +96,23 @@ class ConcurrentReferenceHashMapTests {
@Test
void shouldNeedNonNegativeInitialCapacity() {
new ConcurrentReferenceHashMap<Integer, String>(0, 1);
assertThatIllegalArgumentException().isThrownBy(() ->
new TestWeakConcurrentCache<Integer, String>(-1, 1))
.withMessageContaining("Initial capacity must not be negative");
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 1));
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(-1, 1))
.withMessageContaining("Initial capacity must not be negative");
}
@Test
void shouldNeedPositiveLoadFactor() {
new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1);
assertThatIllegalArgumentException().isThrownBy(() ->
new TestWeakConcurrentCache<Integer, String>(0, 0.0f, 1))
.withMessageContaining("Load factor must be positive");
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.1f, 1));
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(0, 0.0f, 1))
.withMessageContaining("Load factor must be positive");
}
@Test
void shouldNeedPositiveConcurrencyLevel() {
new ConcurrentReferenceHashMap<Integer, String>(1, 1);
assertThatIllegalArgumentException().isThrownBy(() ->
new TestWeakConcurrentCache<Integer, String>(1, 0))
.withMessageContaining("Concurrency level must be positive");
assertThatNoException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 1));
assertThatIllegalArgumentException().isThrownBy(() -> new ConcurrentReferenceHashMap<Integer, String>(1, 0))
.withMessageContaining("Concurrency level must be positive");
}
@Test