[JAVA-18123] Upgraded algorithms-modules to java 11 + Upgraded unit t… (#13437)
* [JAVA-18123] Upgraded algorithms-modules to java 11 + Upgraded unit tests to junit5 * [JAVA-18123] Clean up properties --------- Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
package com.baeldung.algorithms.bynumber;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class NaturalOrderComparatorsUnitTest {
|
||||
class NaturalOrderComparatorsUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenSimpleStringsContainingIntsAndDoubles_whenSortedByRegex_checkSortingCorrect() {
|
||||
void givenSimpleStringsContainingIntsAndDoubles_whenSortedByRegex_checkSortingCorrect() {
|
||||
|
||||
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3d");
|
||||
|
||||
@@ -25,7 +27,7 @@ public class NaturalOrderComparatorsUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSimpleStringsContainingIntsAndDoublesWithAnInvalidNumber_whenSortedByRegex_checkSortingCorrect() {
|
||||
void givenSimpleStringsContainingIntsAndDoublesWithAnInvalidNumber_whenSortedByRegex_checkSortingCorrect() {
|
||||
|
||||
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.4", "d2.3.3d");
|
||||
|
||||
@@ -39,7 +41,7 @@ public class NaturalOrderComparatorsUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAllForseenProblems_whenSortedByRegex_checkSortingCorrect() {
|
||||
void givenAllForseenProblems_whenSortedByRegex_checkSortingCorrect() {
|
||||
|
||||
List<String> testStrings = Arrays.asList("a1", "b3", "c4", "d2.2", "d2.f4", "d2.3.3d");
|
||||
|
||||
@@ -53,7 +55,7 @@ public class NaturalOrderComparatorsUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenComplexStringsContainingSeparatedNumbers_whenSortedByRegex_checkNumbersCondensedAndSorted() {
|
||||
void givenComplexStringsContainingSeparatedNumbers_whenSortedByRegex_checkNumbersCondensedAndSorted() {
|
||||
|
||||
List<String> testStrings = Arrays.asList("a1b2c5", "b3ght3.2", "something65.thensomething5"); //125, 33.2, 65.5
|
||||
|
||||
@@ -66,7 +68,7 @@ public class NaturalOrderComparatorsUnitTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenStringsNotContainingNumbers_whenSortedByRegex_checkOrderNotChanged() {
|
||||
void givenStringsNotContainingNumbers_whenSortedByRegex_checkOrderNotChanged() {
|
||||
|
||||
List<String> testStrings = Arrays.asList("a", "c", "d", "e");
|
||||
List<String> expected = new ArrayList<>(testStrings);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.baeldung.algorithms.gravitysort;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public class GravitySortUnitTest {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class GravitySortUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenIntegerArray_whenSortedWithGravitySort_thenGetSortedArray() {
|
||||
void givenIntegerArray_whenSortedWithGravitySort_thenGetSortedArray() {
|
||||
int[] actual = { 9, 9, 100, 3, 57, 12, 3, 78, 0, 2, 2, 40, 21, 9 };
|
||||
int[] expected = { 0, 2, 2, 3, 3, 9, 9, 9, 12, 21, 40, 57, 78, 100 };
|
||||
GravitySort.sort(actual);
|
||||
Assert.assertArrayEquals(expected, actual);
|
||||
assertArrayEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
package com.baeldung.algorithms.inoutsort;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class InOutSortUnitTest {
|
||||
class InOutSortUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenArray_whenInPlaceSort_thenReversed() {
|
||||
void givenArray_whenInPlaceSort_thenReversed() {
|
||||
int[] input = {1, 2, 3, 4, 5, 6, 7};
|
||||
int[] expected = {7, 6, 5, 4, 3, 2, 1};
|
||||
assertArrayEquals("the two arrays are not equal", expected, InOutSort.reverseInPlace(input));
|
||||
assertArrayEquals(expected, InOutSort.reverseInPlace(input), "the two arrays are not equal");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenArray_whenOutOfPlaceSort_thenReversed() {
|
||||
void givenArray_whenOutOfPlaceSort_thenReversed() {
|
||||
int[] input = {1, 2, 3, 4, 5, 6, 7};
|
||||
int[] expected = {7, 6, 5, 4, 3, 2, 1};
|
||||
assertArrayEquals("the two arrays are not equal", expected, InOutSort.reverseOutOfPlace(input));
|
||||
assertArrayEquals(expected, InOutSort.reverseOutOfPlace(input), "the two arrays are not equal");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
package com.baeldung.algorithms.quicksort;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public class BentleyMcilroyPartitioningUnitTest {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class BentleyMcilroyPartitioningUnitTest {
|
||||
|
||||
@Test
|
||||
public void given_IntegerArray_whenSortedWithBentleyMcilroyPartitioning_thenGetSortedArray() {
|
||||
void given_IntegerArray_whenSortedWithBentleyMcilroyPartitioning_thenGetSortedArray() {
|
||||
int[] actual = {3, 2, 2, 2, 3, 7, 7, 3, 2, 2, 7, 3, 3};
|
||||
int[] expected = {2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 7, 7, 7};
|
||||
BentleyMcIlroyPartioning.quicksort(actual, 0, actual.length - 1);
|
||||
Assert.assertArrayEquals(expected, actual);
|
||||
assertArrayEquals(expected, actual);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.baeldung.algorithms.quicksort;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
public class DNFThreeWayQuickSortUnitTest {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DNFThreeWayQuickSortUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenIntegerArray_whenSortedWithThreeWayQuickSort_thenGetSortedArray() {
|
||||
void givenIntegerArray_whenSortedWithThreeWayQuickSort_thenGetSortedArray() {
|
||||
int[] actual = {3, 5, 5, 5, 3, 7, 7, 3, 5, 5, 7, 3, 3};
|
||||
int[] expected = {3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 7, 7, 7};
|
||||
DutchNationalFlagPartioning.quicksort(actual, 0, actual.length - 1);
|
||||
Assert.assertArrayEquals(expected, actual);
|
||||
assertArrayEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user