mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Format code with prettier (#3375)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package com.thealgorithms.searches;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class QuickSelectTest {
|
||||
|
||||
@Test
|
||||
void quickSelectMinimumOfOneElement() {
|
||||
List<Integer> elements = Collections.singletonList(42);
|
||||
@@ -181,8 +181,8 @@ class QuickSelectTest {
|
||||
@Test
|
||||
void quickSelectNullList() {
|
||||
NullPointerException exception = assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> QuickSelect.select(null, 0)
|
||||
NullPointerException.class,
|
||||
() -> QuickSelect.select(null, 0)
|
||||
);
|
||||
String expectedMsg = "The list of elements must not be null.";
|
||||
assertEquals(expectedMsg, exception.getMessage());
|
||||
@@ -192,8 +192,8 @@ class QuickSelectTest {
|
||||
void quickSelectEmptyList() {
|
||||
List<String> objects = Collections.emptyList();
|
||||
IllegalArgumentException exception = assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> QuickSelect.select(objects, 0)
|
||||
IllegalArgumentException.class,
|
||||
() -> QuickSelect.select(objects, 0)
|
||||
);
|
||||
String expectedMsg = "The list of elements must not be empty.";
|
||||
assertEquals(expectedMsg, exception.getMessage());
|
||||
@@ -202,8 +202,8 @@ class QuickSelectTest {
|
||||
@Test
|
||||
void quickSelectIndexOutOfLeftBound() {
|
||||
IndexOutOfBoundsException exception = assertThrows(
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> QuickSelect.select(Collections.singletonList(1), -1)
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> QuickSelect.select(Collections.singletonList(1), -1)
|
||||
);
|
||||
String expectedMsg = "The index must not be negative.";
|
||||
assertEquals(expectedMsg, exception.getMessage());
|
||||
@@ -212,10 +212,11 @@ class QuickSelectTest {
|
||||
@Test
|
||||
void quickSelectIndexOutOfRightBound() {
|
||||
IndexOutOfBoundsException exception = assertThrows(
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> QuickSelect.select(Collections.singletonList(1), 1)
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> QuickSelect.select(Collections.singletonList(1), 1)
|
||||
);
|
||||
String expectedMsg = "The index must be less than the number of elements.";
|
||||
String expectedMsg =
|
||||
"The index must be less than the number of elements.";
|
||||
assertEquals(expectedMsg, exception.getMessage());
|
||||
}
|
||||
|
||||
@@ -229,12 +230,15 @@ class QuickSelectTest {
|
||||
}
|
||||
|
||||
private static List<Character> generateRandomCharacters(int n) {
|
||||
return RANDOM.ints(n, ASCII_A, ASCII_Z)
|
||||
.mapToObj(i -> (char) i)
|
||||
.collect(Collectors.toList());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user