Repository: apache/kafka
File: group-coordinator/src/test/java/org/apache/kafka/coordinator/group/assignor/RangeSetTest.java (Java)

Code before:
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.kafka.coordinator.group.assignor;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;


public class RangeSetTest {
    @Test
    void testOverflow() {
        // This range is the maximum size we allow.
        new RangeSet(0, Integer.MAX_VALUE);

        assertThrows(IllegalArgumentException.class, () -> new RangeSet(-1, Integer.MAX_VALUE));
    }

    @Test
    void testSize() {
        RangeSet rangeSet = new RangeSet(5, 10);
        assertEquals(5, rangeSet.size());

        RangeSet emptyRangeSet = new RangeSet(5, -2);
        assertEquals(0, emptyRangeSet.size());
    }

    @Test
    void testIsEmpty() {
        RangeSet rangeSet = new RangeSet(5, 5);
        assertTrue(rangeSet.isEmpty());

        RangeSet emptyRangeSet = new RangeSet(5, -2);
        assertTrue(emptyRangeSet.isEmpty());
    }

    @Test
    void testContains() {
        RangeSet rangeSet = new RangeSet(5, 10);

Review comment (suggestion):
```suggestion
        assertDoesNotThrow(() -> new RangeSet(0, Integer.MAX_VALUE));
```

Code after:
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.kafka.coordinator.group.assignor;

import org.junit.jupiter.api.Test;

import java.util.HashSet;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;


public class RangeSetTest {
    @Test
    void testNegativeSize() {
        assertThrows(IllegalArgumentException.class, () -> new RangeSet(0, -1));
    }

    @Test
    void testOverflow() {
        // This range is the maximum size we allow.
        assertDoesNotThrow(() -> new RangeSet(0, Integer.MAX_VALUE));

        assertThrows(IllegalArgumentException.class, () -> new RangeSet(-1, Integer.MAX_VALUE));
    }

    @Test
    void testSize() {
        RangeSet rangeSet = new RangeSet(5, 10);
        assertEquals(5, rangeSet.size());
    }

    @Test
    void testIsEmpty() {
        RangeSet rangeSet = new RangeSet(5, 5);
        assertTrue(rangeSet.isEmpty());
    }

    @Test
    void testContains() {
        RangeSet rangeSet = new RangeSet(5, 10);