@VisibleForTesting
    static int computeRequiredCapacity(int expectedSize, float loadFactor) {
        Preconditions.checkArgument(expectedSize >= 0);
        Preconditions.checkArgument(loadFactor > 0f);
        if (expectedSize <= 2) {
            return expectedSize + 1;
        }
        return expectedSize < (Integer.MAX_VALUE / 2 + 1)
                ? (int) Math.ceil(expectedSize / loadFactor)
                : Integer.MAX_VALUE;
    }
@Test
    void testComputeCapacity() {
        assertThat(CollectionUtil.computeRequiredCapacity(0, HASH_MAP_DEFAULT_LOAD_FACTOR)).isOne();
        assertThat(CollectionUtil.computeRequiredCapacity(1, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(2);
        assertThat(CollectionUtil.computeRequiredCapacity(2, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(3);
        assertThat(CollectionUtil.computeRequiredCapacity(3, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(4);
        assertThat(CollectionUtil.computeRequiredCapacity(4, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(6);
        assertThat(CollectionUtil.computeRequiredCapacity(5, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(7);
        assertThat(CollectionUtil.computeRequiredCapacity(6, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(8);
        assertThat(CollectionUtil.computeRequiredCapacity(7, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(10);
        assertThat(CollectionUtil.computeRequiredCapacity(8, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(11);
        assertThat(CollectionUtil.computeRequiredCapacity(100, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(134);
        assertThat(CollectionUtil.computeRequiredCapacity(1000, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(1334);
        assertThat(CollectionUtil.computeRequiredCapacity(10000, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(13334);

        assertThat(
                        CollectionUtil.computeRequiredCapacity(
                                Integer.MAX_VALUE / 2, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(1431655808);

        assertThat(
                        CollectionUtil.computeRequiredCapacity(
                                1 + Integer.MAX_VALUE / 2, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isEqualTo(Integer.MAX_VALUE);

        assertThatThrownBy(
                        () ->
                                CollectionUtil.computeRequiredCapacity(
                                        -1, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isInstanceOf(IllegalArgumentException.class);

        assertThatThrownBy(
                        () ->
                                CollectionUtil.computeRequiredCapacity(
                                        Integer.MIN_VALUE, HASH_MAP_DEFAULT_LOAD_FACTOR))
                .isInstanceOf(IllegalArgumentException.class);
    }