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:
Narek Karapetian
2023-01-01 06:50:56 -08:00
committed by GitHub
parent ce55420418
commit 1eedaeb073
7 changed files with 222 additions and 324 deletions

View File

@ -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;
}
}