mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-27 22:43:30 +08:00
Add Binary Insertion Sort (#3206)
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
package com.thealgorithms.sorts;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user