Add Bead Sort (#3761)

This commit is contained in:
Hyun
2022-11-10 04:33:30 +09:00
committed by GitHub
parent b8d6b1a9b0
commit 4990f791a6
2 changed files with 87 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package com.thealgorithms.sorts;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import org.junit.jupiter.api.Test;
public class BeadSortTest {
//BeadSort can't sort negative number, Character, String. It can sort positive number only
private BeadSort beadSort = new BeadSort();
@Test
public void beadSortEmptyArray() {
int[] inputArray = {};
int[] outputArray = beadSort.sort(inputArray);
int[] expectedOutput = {};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void beadSortSingleIntegerArray() {
int[] inputArray = { 4 };
int[] outputArray = beadSort.sort(inputArray);
int[] expectedOutput = { 4 };
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void bogoSortNonDuplicateIntegerArray() {
int[] inputArray = { 6, 1, 99, 27, 15, 23, 36 };
int[] outputArray = beadSort.sort(inputArray);
int[] expectedOutput = {1, 6, 15, 23, 27, 36, 99};
assertArrayEquals(outputArray, expectedOutput);
}
@Test
public void bogoSortDuplicateIntegerArray() {
int[] inputArray = { 6, 1, 27, 15, 23, 27, 36, 23 };
int[] outputArray = beadSort.sort(inputArray);
int[] expectedOutput = {1, 6, 15, 23, 23, 27, 27, 36};
assertArrayEquals(outputArray, expectedOutput);
}
}