mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 15:02:46 +08:00
Refactoring BinaryInsertionSort according to common SortAlgorithm approach (#5239)
* Refactoring BinaryInsertionSort according to common SortAlgorithm approach * Formatting has been fixed * Refactoring tests for BinaryInsertionSort according to SortingAlgorithmTest * Removing redundant tests and improving variable readability --------- Co-authored-by: alx <alx@alx.com> Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
@ -1,27 +1,10 @@
|
||||
package com.thealgorithms.sorts;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
class BinaryInsertionSortTest extends SortingAlgorithmTest {
|
||||
private final BinaryInsertionSort binaryInsertionSort = new BinaryInsertionSort();
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class BinaryInsertionSortTest {
|
||||
|
||||
BinaryInsertionSort bis = new BinaryInsertionSort();
|
||||
|
||||
@Test
|
||||
// valid test case
|
||||
public void binaryInsertionSortTestNonDuplicate() {
|
||||
int[] array = {1, 0, 2, 5, 3, 4, 9, 8, 10, 6, 7};
|
||||
int[] expResult = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
int[] actResult = bis.binaryInsertSort(array);
|
||||
assertArrayEquals(expResult, actResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void binaryInsertionSortTestDuplicate() {
|
||||
int[] array = {1, 1, 1, 5, 9, 8, 7, 2, 6};
|
||||
int[] expResult = {1, 1, 1, 2, 5, 6, 7, 8, 9};
|
||||
int[] actResult = bis.binaryInsertSort(array);
|
||||
assertArrayEquals(expResult, actResult);
|
||||
@Override
|
||||
SortAlgorithm getSortAlgorithm() {
|
||||
return binaryInsertionSort;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user