mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 02:04:31 +08:00
Move common tests for sorting algorithms to the base test class (#3782)
* bug fix for CircularBuffer + refactoring + add unit tests * change Insertion sort to classical implementation + add isSorted function to SortUtils + add SortUtilsRandomGenerator for generating random values and arrays * little fix * move all common tests to SortingAlgorithmTest and utilize them Co-authored-by: Debasish Biswas <debasishbsws.abc@gmail.com>
This commit is contained in:
@ -112,4 +112,11 @@ final class SortUtils {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static <T extends Comparable<T>> boolean isSorted(List<T> list) {
|
||||
for (int i = 1; i < list.size(); i++)
|
||||
if (less(list.get(i), list.get(i - 1)))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user