style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@@ -180,10 +180,8 @@ class QuickSelectTest {
@Test
void quickSelectNullList() {
NullPointerException exception = assertThrows(
NullPointerException.class,
() -> QuickSelect.select(null, 0)
);
NullPointerException exception
= assertThrows(NullPointerException.class, () -> QuickSelect.select(null, 0));
String expectedMsg = "The list of elements must not be null.";
assertEquals(expectedMsg, exception.getMessage());
}
@@ -191,32 +189,25 @@ class QuickSelectTest {
@Test
void quickSelectEmptyList() {
List<String> objects = Collections.emptyList();
IllegalArgumentException exception = assertThrows(
IllegalArgumentException.class,
() -> QuickSelect.select(objects, 0)
);
IllegalArgumentException exception
= assertThrows(IllegalArgumentException.class, () -> QuickSelect.select(objects, 0));
String expectedMsg = "The list of elements must not be empty.";
assertEquals(expectedMsg, exception.getMessage());
}
@Test
void quickSelectIndexOutOfLeftBound() {
IndexOutOfBoundsException exception = assertThrows(
IndexOutOfBoundsException.class,
() -> QuickSelect.select(Collections.singletonList(1), -1)
);
IndexOutOfBoundsException exception = assertThrows(IndexOutOfBoundsException.class,
() -> QuickSelect.select(Collections.singletonList(1), -1));
String expectedMsg = "The index must not be negative.";
assertEquals(expectedMsg, exception.getMessage());
}
@Test
void quickSelectIndexOutOfRightBound() {
IndexOutOfBoundsException exception = assertThrows(
IndexOutOfBoundsException.class,
() -> QuickSelect.select(Collections.singletonList(1), 1)
);
String expectedMsg =
"The index must be less than the number of elements.";
IndexOutOfBoundsException exception = assertThrows(IndexOutOfBoundsException.class,
() -> QuickSelect.select(Collections.singletonList(1), 1));
String expectedMsg = "The index must be less than the number of elements.";
assertEquals(expectedMsg, exception.getMessage());
}
@@ -230,15 +221,12 @@ class QuickSelectTest {
}
private static List<Character> generateRandomCharacters(int n) {
return RANDOM
.ints(n, ASCII_A, ASCII_Z)
return RANDOM.ints(n, ASCII_A, ASCII_Z)
.mapToObj(i -> (char) i)
.collect(Collectors.toList());
}
private static <T extends Comparable<T>> List<T> getSortedCopyOfList(
List<T> list
) {
private static <T extends Comparable<T>> List<T> getSortedCopyOfList(List<T> list) {
return list.stream().sorted().collect(Collectors.toList());
}
}