style: enable MethodName in CheckStyle (#5182)

enabled: MethodName in CheckStyle
This commit is contained in:
Godwill Christopher
2024-05-27 01:06:06 -06:00
committed by GitHub
parent ea4dc15a24
commit 295e7436b1
53 changed files with 225 additions and 225 deletions

View File

@ -14,14 +14,14 @@ public class LeftistHeapTest {
heap.insert(2);
heap.insert(3);
heap.insert(1);
heap.in_order();
Assertions.assertTrue(heap.in_order().toString().equals("[6, 2, 3, 1]"));
Assertions.assertTrue(heap.extract_min() == 1);
Assertions.assertTrue(heap.in_order().toString().equals("[6, 2, 3]"));
heap.inOrder();
Assertions.assertTrue(heap.inOrder().toString().equals("[6, 2, 3, 1]"));
Assertions.assertTrue(heap.extractMin() == 1);
Assertions.assertTrue(heap.inOrder().toString().equals("[6, 2, 3]"));
heap.insert(8);
heap.insert(12);
heap.insert(4);
Assertions.assertTrue(heap.in_order().toString().equals("[8, 3, 12, 2, 6, 4]"));
Assertions.assertTrue(heap.inOrder().toString().equals("[8, 3, 12, 2, 6, 4]"));
heap.clear();
Assertions.assertTrue(heap.isEmpty());
}

View File

@ -166,7 +166,7 @@ public class SinglyLinkedListTest {
}
// This is Recursive Reverse List Test
// Test to check whether the method reverseListRec() works fine
void RecursiveReverseList() {
void recursiveReverseList() {
// Create a linked list: 1 -> 2 -> 3 -> 4 -> 5
SinglyLinkedList list = createSampleList(5);
@ -182,7 +182,7 @@ public class SinglyLinkedListTest {
}
@Test
void RecursiveReverseListNullPointer() {
void recursiveReverseListNullPointer() {
// Create an empty linked list
SinglyLinkedList list = new SinglyLinkedList();
Node first = list.getHead();
@ -195,7 +195,7 @@ public class SinglyLinkedListTest {
}
@Test
void RecursiveReverseListTest() {
void recursiveReverseListTest() {
// Create a linked list with values from 1 to 20
SinglyLinkedList list = createSampleList(20);

View File

@ -12,7 +12,7 @@ class StrassenMatrixMultiplicationTest {
// and has to be a Square Matrix
@Test
public void StrassenMatrixMultiplicationTest2x2() {
public void strassenMatrixMultiplicationTest2x2() {
int[][] A = {{1, 2}, {3, 4}};
int[][] B = {{5, 6}, {7, 8}};
int[][] expResult = {{19, 22}, {43, 50}};
@ -21,7 +21,7 @@ class StrassenMatrixMultiplicationTest {
}
@Test
void StrassenMatrixMultiplicationTest4x4() {
void strassenMatrixMultiplicationTest4x4() {
int[][] A = {{1, 2, 5, 4}, {9, 3, 0, 6}, {4, 6, 3, 1}, {0, 2, 0, 6}};
int[][] B = {{1, 0, 4, 1}, {1, 2, 0, 2}, {0, 3, 1, 3}, {1, 8, 1, 2}};
int[][] expResult = {{7, 51, 13, 28}, {18, 54, 42, 27}, {11, 29, 20, 27}, {8, 52, 6, 16}};
@ -30,7 +30,7 @@ class StrassenMatrixMultiplicationTest {
}
@Test
void StrassenMatrixMultiplicationTestNegetiveNumber4x4() {
void strassenMatrixMultiplicationTestNegativeNumber4x4() {
int[][] A = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
int[][] B = {{1, -2, -3, 4}, {4, -3, -2, 1}, {5, -6, -7, 8}, {8, -7, -6, -5}};
int[][] expResult = {{56, -54, -52, 10}, {128, -126, -124, 42}, {200, -198, -196, 74}, {272, -270, -268, 106}};

View File

@ -9,7 +9,7 @@ public class KnapsackMemoizationTest {
KnapsackMemoization knapsackMemoization = new KnapsackMemoization();
@Test
void Test1() {
void test1() {
int[] weight = {1, 3, 4, 5};
int[] value = {1, 4, 5, 7};
int capacity = 10;
@ -17,7 +17,7 @@ public class KnapsackMemoizationTest {
}
@Test
void Test2() {
void test2() {
int[] weight = {95, 4, 60, 32, 23, 72, 80, 62, 65, 46};
int[] value = {55, 10, 47, 5, 4, 50, 8, 61, 85, 87};
int capacity = 269;
@ -25,7 +25,7 @@ public class KnapsackMemoizationTest {
}
@Test
void Test3() {
void test3() {
int[] weight = {10, 20, 30};
int[] value = {60, 100, 120};
int capacity = 50;

View File

@ -42,7 +42,7 @@ public class LongestIncreasingSubsequenceTests {
{3, new int[] {1, 1, 2, 2, 2, 3, 3, 3, 3}},
};
final List<IntArrayToInt> methods = Arrays.asList(LongestIncreasingSubsequence::LIS, LongestIncreasingSubsequence::findLISLen);
final List<IntArrayToInt> methods = Arrays.asList(LongestIncreasingSubsequence::lis, LongestIncreasingSubsequence::findLISLen);
return Stream.of(testData).flatMap(input -> methods.stream().map(method -> Arguments.of(input[0], input[1], method)));
}

View File

@ -8,52 +8,52 @@ import org.junit.jupiter.api.Test;
public class UniquePathsTests {
@Test
public void testUniquePaths_3x3() {
public void testUniquePaths3x3() {
assertEquals(6, UniquePaths.uniquePaths(3, 3));
}
@Test
public void testUniquePaths_1x1() {
public void testUniquePaths1x1() {
assertEquals(1, UniquePaths.uniquePaths(1, 1));
}
@Test
public void testUniquePaths_3x7() {
public void testUniquePaths3x7() {
assertEquals(28, UniquePaths.uniquePaths(3, 7));
}
@Test
public void testUniquePaths_7x3() {
public void testUniquePaths7x3() {
assertEquals(28, UniquePaths.uniquePaths(7, 3));
}
@Test
public void testUniquePaths_100x100() {
public void testUniquePaths100x100() {
assertThrows(ArithmeticException.class, () -> UniquePaths.uniquePaths(100, 100));
}
@Test
public void testUniquePaths2_3x3() {
public void testUniquePathsII3x3() {
assertEquals(6, UniquePaths.uniquePaths2(3, 3));
}
@Test
public void testUniquePaths2_1x1() {
public void testUniquePathsII1x1() {
assertEquals(1, UniquePaths.uniquePaths2(1, 1));
}
@Test
public void testUniquePaths2_3x7() {
public void testUniquePathsII3x7() {
assertEquals(28, UniquePaths.uniquePaths2(3, 7));
}
@Test
public void testUniquePaths2_7x3() {
public void testUniquePathsII7x3() {
assertEquals(28, UniquePaths.uniquePaths2(7, 3));
}
@Test
public void testUniquePaths2_100x100() {
public void testUniquePathsII100x100() {
assertThrows(ArithmeticException.class, () -> UniquePaths.uniquePaths2(100, 100));
}
}

View File

@ -8,25 +8,25 @@ public class AverageTest {
private static final double SMALL_VALUE = 0.00001d;
@Test
public void testAverage_double_12() {
public void testAverageDouble12() {
double[] numbers = {3d, 6d, 9d, 12d, 15d, 18d, 21d};
Assertions.assertEquals(12d, Average.average(numbers), SMALL_VALUE);
}
@Test
public void testAverage_double_20() {
public void testAverageDouble20() {
double[] numbers = {5d, 10d, 15d, 20d, 25d, 30d, 35d};
Assertions.assertEquals(20d, Average.average(numbers), SMALL_VALUE);
}
@Test
public void testAverage_double_4_5() {
public void testAverageDouble() {
double[] numbers = {1d, 2d, 3d, 4d, 5d, 6d, 7d, 8d};
Assertions.assertEquals(4.5d, Average.average(numbers), SMALL_VALUE);
}
@Test
public void testAverage_int_5() {
public void testAverageInt() {
int[] numbers = {2, 4, 10};
Assertions.assertEquals(5, Average.average(numbers));
}

View File

@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
public class PythagoreanTripleTest {
@Test
public void Testpythagoreantriple() {
public void testPythagoreanTriple() {
assertTrue(PythagoreanTriple.isPythagTriple(3, 4, 5));
assertTrue(PythagoreanTriple.isPythagTriple(6, 8, 10));
assertTrue(PythagoreanTriple.isPythagTriple(9, 12, 15));

View File

@ -7,21 +7,21 @@ public class SquareRootwithBabylonianMethodTest {
@Test
void testfor4() {
Assertions.assertEquals(2, SquareRootWithBabylonianMethod.square_Root(4));
Assertions.assertEquals(2, SquareRootWithBabylonianMethod.squareRoot(4));
}
@Test
void testfor1() {
Assertions.assertEquals(1, SquareRootWithBabylonianMethod.square_Root(1));
Assertions.assertEquals(1, SquareRootWithBabylonianMethod.squareRoot(1));
}
@Test
void testfor2() {
Assertions.assertEquals(1.4142135381698608, SquareRootWithBabylonianMethod.square_Root(2));
Assertions.assertEquals(1.4142135381698608, SquareRootWithBabylonianMethod.squareRoot(2));
}
@Test
void testfor625() {
Assertions.assertEquals(25, SquareRootWithBabylonianMethod.square_Root(625));
Assertions.assertEquals(25, SquareRootWithBabylonianMethod.squareRoot(625));
}
}

View File

@ -11,6 +11,6 @@ class CountCharTest {
String input = "12345";
int expectedValue = 5;
assertEquals(expectedValue, CountChar.CountCharacters(input));
assertEquals(expectedValue, CountChar.countCharacters(input));
}
}

View File

@ -10,48 +10,48 @@ public class KadaneAlogrithmTest {
@Test
void testForOneElement() {
int[] a = {-1};
assertTrue(KadaneAlgorithm.max_Sum(a, -1));
assertTrue(KadaneAlgorithm.maxSum(a, -1));
}
@Test
void testForTwoElements() {
int[] a = {-2, 1};
assertTrue(KadaneAlgorithm.max_Sum(a, 1));
assertTrue(KadaneAlgorithm.maxSum(a, 1));
}
@Test
void testForThreeElements() {
int[] a = {5, 3, 12};
assertTrue(KadaneAlgorithm.max_Sum(a, 20));
assertTrue(KadaneAlgorithm.maxSum(a, 20));
}
@Test
void testForFourElements() {
int[] a = {-1, -3, -7, -4};
assertTrue(KadaneAlgorithm.max_Sum(a, -1));
assertTrue(KadaneAlgorithm.maxSum(a, -1));
}
@Test
void testForFiveElements() {
int[] a = {4, 5, 3, 0, 2};
assertTrue(KadaneAlgorithm.max_Sum(a, 14));
assertTrue(KadaneAlgorithm.maxSum(a, 14));
}
@Test
void testForSixElements() {
int[] a = {-43, -45, 47, 12, 87, -13};
assertTrue(KadaneAlgorithm.max_Sum(a, 146));
assertTrue(KadaneAlgorithm.maxSum(a, 146));
}
@Test
void testForSevenElements() {
int[] a = {9, 8, 2, 23, 13, 6, 7};
assertTrue(KadaneAlgorithm.max_Sum(a, 68));
assertTrue(KadaneAlgorithm.maxSum(a, 68));
}
@Test
void testForEightElements() {
int[] a = {9, -5, -5, -2, 4, 5, 0, 1};
assertTrue(KadaneAlgorithm.max_Sum(a, 10));
assertTrue(KadaneAlgorithm.maxSum(a, 10));
}
}

View File

@ -25,6 +25,6 @@ public class LineSweepTest {
@Test
void testForMaximumEndPoint() {
int[][] arr = {{10, 20}, {1, 100}, {14, 16}, {1, 8}};
assertEquals(100, LineSweep.FindMaximumEndPoint(arr));
assertEquals(100, LineSweep.findMaximumEndPoint(arr));
}
}

View File

@ -6,27 +6,27 @@ import org.junit.jupiter.api.Test;
public class MaximumSumOfDistinctSubarraysWithLengthKTest {
@Test
public void SampleTestCase1() {
public void sampleTestCase1() {
assertEquals(15, MaximumSumOfDistinctSubarraysWithLengthK.maximumSubarraySum(3, 1, 5, 4, 2, 9, 9, 9));
}
@Test
public void SampleTestCase2() {
public void sampleTestCase2() {
assertEquals(0, MaximumSumOfDistinctSubarraysWithLengthK.maximumSubarraySum(3, 4, 4, 4));
}
@Test
public void SampleTestCase3() {
public void sampleTestCase3() {
assertEquals(12, MaximumSumOfDistinctSubarraysWithLengthK.maximumSubarraySum(3, 9, 9, 9, 1, 2, 3));
}
@Test
public void EdgeCase1() {
public void edgeCase1() {
assertEquals(0, MaximumSumOfDistinctSubarraysWithLengthK.maximumSubarraySum(0, 9, 9, 9));
}
@Test
public void EdgeCase2() {
public void edgeCase2() {
assertEquals(0, MaximumSumOfDistinctSubarraysWithLengthK.maximumSubarraySum(5, 9, 9, 9));
}
}

View File

@ -74,7 +74,7 @@ class SJFSchedulingTest {
}
@Test
void schedulingOf_TwoProcesses() {
void schedulingOfTwoProcesses() {
initialisation0();
SJFScheduling a = new SJFScheduling(process);
a.scheduleProcesses();
@ -83,7 +83,7 @@ class SJFSchedulingTest {
}
@Test
void schedulingOfA_ShortestJobArrivingLast() {
void schedulingOfAShortestJobArrivingLast() {
initialisation2();
SJFScheduling a = new SJFScheduling(process);
a.scheduleProcesses();
@ -92,7 +92,7 @@ class SJFSchedulingTest {
assertEquals("2", a.schedule.get(2));
}
@Test
void scheduling_WithProcessesNotComingBackToBack() {
void schedulingWithProcessesNotComingBackToBack() {
initialisation3();
SJFScheduling a = new SJFScheduling(process);
a.scheduleProcesses();
@ -101,7 +101,7 @@ class SJFSchedulingTest {
assertEquals("3", a.schedule.get(2));
}
@Test
void schedulingOf_nothing() {
void schedulingOfNothing() {
process = new ArrayList<>();
SJFScheduling a = new SJFScheduling(process);
a.scheduleProcesses();

View File

@ -19,7 +19,7 @@ class SRTFSchedulingTest {
}
@Test
public void Constructor() {
public void constructor() {
initialization();
SRTFScheduling s = new SRTFScheduling(processes);
assertEquals(3, s.processes.get(0).getBurstTime());

View File

@ -10,11 +10,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestMiddle() {
public void binarySearch2dArrayTestMiddle() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 6;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(1, ans[0]);
assertEquals(1, ans[1]);
@ -22,11 +22,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestMiddleSide() {
public void binarySearch2dArrayTestMiddleSide() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 8;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(1, ans[0]);
assertEquals(3, ans[1]);
@ -34,11 +34,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestUpper() {
public void binarySearch2dArrayTestUpper() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 2;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(0, ans[0]);
assertEquals(1, ans[1]);
@ -46,11 +46,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestUpperSide() {
public void binarySearch2dArrayTestUpperSide() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 1;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(0, ans[0]);
assertEquals(0, ans[1]);
@ -58,11 +58,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestLower() {
public void binarySearch2dArrayTestLower() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 10;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(2, ans[0]);
assertEquals(1, ans[1]);
@ -70,11 +70,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestLowerSide() {
public void binarySearch2dArrayTestLowerSide() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 11;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(2, ans[0]);
assertEquals(2, ans[1]);
@ -82,11 +82,11 @@ public class BinarySearch2dArrayTest {
@Test
// valid test case
public void BinarySearch2dArrayTestNotFound() {
public void binarySearch2dArrayTestNotFound() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 101;
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(-1, ans[0]);
assertEquals(-1, ans[1]);
@ -96,13 +96,13 @@ public class BinarySearch2dArrayTest {
* Test if the method works with input arrays consisting only of one row.
*/
@Test
public void BinarySearch2dArrayTestOneRow() {
public void binarySearch2dArrayTestOneRow() {
int[][] arr = {{1, 2, 3, 4}};
int target = 2;
// Assert that the requirement, that the array only has one row, is fulfilled.
assertEquals(arr.length, 1);
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(0, ans[0]);
assertEquals(1, ans[1]);
@ -112,13 +112,13 @@ public class BinarySearch2dArrayTest {
* Test if the method works with the target in the middle of the input.
*/
@Test
public void BinarySearch2dArrayTestTargetInMiddle() {
public void binarySearch2dArrayTestTargetInMiddle() {
int[][] arr = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}};
int target = 8;
// Assert that the requirement, that the target is in the middle row and middle column, is
// fulfilled.
assertEquals(arr[arr.length / 2][arr[0].length / 2], target);
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(1, ans[0]);
assertEquals(2, ans[1]);
@ -129,7 +129,7 @@ public class BinarySearch2dArrayTest {
* in the row above the middle row.
*/
@Test
public void BinarySearch2dArrayTestTargetAboveMiddleRowInMiddleColumn() {
public void binarySearch2dArrayTestTargetAboveMiddleRowInMiddleColumn() {
int[][] arr = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
int target = 3;
@ -137,7 +137,7 @@ public class BinarySearch2dArrayTest {
// in an array with an even number of columns, and on the row "above" the middle row.
assertEquals(arr[0].length % 2, 0);
assertEquals(arr[arr.length / 2 - 1][arr[0].length / 2], target);
int[] ans = BinarySearch2dArray.BinarySearch(arr, target);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(0, ans[0]);
assertEquals(2, ans[1]);
@ -147,11 +147,11 @@ public class BinarySearch2dArrayTest {
* Test if the method works with an empty array.
*/
@Test
public void BinarySearch2dArrayTestEmptyArray() {
public void binarySearch2dArrayTestEmptyArray() {
int[][] arr = {};
int target = 5;
// Assert that an empty array is not valid input for the method.
assertThrows(ArrayIndexOutOfBoundsException.class, () -> BinarySearch2dArray.BinarySearch(arr, target));
assertThrows(ArrayIndexOutOfBoundsException.class, () -> BinarySearch2dArray.binarySearch(arr, target));
}
}

View File

@ -8,55 +8,55 @@ class KMPSearchTest {
@Test
// valid test case
public void KMPSearchTestLast() {
public void kmpSearchTestLast() {
String txt = "ABABDABACDABABCABAB";
String pat = "ABABCABAB";
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.KMPSearch(pat, txt);
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
assertEquals(value, 10);
}
@Test
// valid test case
public void KMPSearchTestFront() {
public void kmpSearchTestFront() {
String txt = "AAAAABAAABA";
String pat = "AAAA";
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.KMPSearch(pat, txt);
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
assertEquals(value, 0);
}
@Test
// valid test case
public void KMPSearchTestMiddle() {
public void kmpSearchTestMiddle() {
String txt = "AAACAAAAAC";
String pat = "AAAA";
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.KMPSearch(pat, txt);
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
assertEquals(value, 4);
}
@Test
// valid test case
public void KMPSearchTestNotFound() {
public void kmpSearchTestNotFound() {
String txt = "AAABAAAA";
String pat = "AAAA";
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.KMPSearch(pat, txt);
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
assertEquals(value, 4);
}
@Test
// not valid test case
public void KMPSearchTest4() {
public void kmpSearchTest4() {
String txt = "AABAAA";
String pat = "AAAA";
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.KMPSearch(pat, txt);
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
assertEquals(value, -1);
}

View File

@ -7,9 +7,9 @@ import org.junit.jupiter.api.Test;
public class OrderAgnosticBinarySearchTest {
@Test
// valid Test Case
public void ElementInMiddle() {
public void elementInMiddle() {
int[] arr = {10, 20, 30, 40, 50};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 30);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 30);
System.out.println(answer);
int expected = 2;
assertEquals(expected, answer);
@ -17,9 +17,9 @@ public class OrderAgnosticBinarySearchTest {
@Test
// valid Test Case
public void RightHalfDescOrder() {
public void rightHalfDescOrder() {
int[] arr = {50, 40, 30, 20, 10};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 10);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 10);
System.out.println(answer);
int expected = 4;
assertEquals(expected, answer);
@ -27,9 +27,9 @@ public class OrderAgnosticBinarySearchTest {
@Test
// valid test case
public void LeftHalfDescOrder() {
public void leftHalfDescOrder() {
int[] arr = {50, 40, 30, 20, 10};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 50);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 50);
System.out.println(answer);
int expected = 0;
assertEquals(expected, answer);
@ -37,9 +37,9 @@ public class OrderAgnosticBinarySearchTest {
@Test
// valid test case
public void RightHalfAscOrder() {
public void rightHalfAscOrder() {
int[] arr = {10, 20, 30, 40, 50};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 50);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 50);
System.out.println(answer);
int expected = 4;
assertEquals(expected, answer);
@ -47,9 +47,9 @@ public class OrderAgnosticBinarySearchTest {
@Test
// valid test case
public void LeftHalfAscOrder() {
public void leftHalfAscOrder() {
int[] arr = {10, 20, 30, 40, 50};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 10);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 10);
System.out.println(answer);
int expected = 0;
assertEquals(expected, answer);
@ -57,9 +57,9 @@ public class OrderAgnosticBinarySearchTest {
@Test
// valid test case
public void ElementNotFound() {
public void elementNotFound() {
int[] arr = {10, 20, 30, 40, 50};
int answer = OrderAgnosticBinarySearch.BinSearchAlgo(arr, 0, arr.length - 1, 100);
int answer = OrderAgnosticBinarySearch.binSearchAlgo(arr, 0, arr.length - 1, 100);
System.out.println(answer);
int expected = -1;
assertEquals(expected, answer);

View File

@ -9,7 +9,7 @@ class RabinKarpAlgorithmTest {
@ParameterizedTest
@CsvSource({"This is an example for rabin karp algorithmn, algorithmn, 101", "AAABBDDG, AAA, 137", "AAABBCCBB, BBCC, 101", "AAABBCCBB, BBCC, 131", "AAAABBBBCCC, CCC, 41", "ABCBCBCAAB, AADB, 293", "Algorithm The Algorithm, Algorithm, 101"})
void RabinKarpAlgorithmTestExample(String txt, String pat, int q) {
void rabinKarpAlgorithmTestExample(String txt, String pat, int q) {
int indexFromOurAlgorithm = RabinKarpAlgorithm.search(pat, txt, q);
int indexFromLinearSearch = txt.indexOf(pat);
assertEquals(indexFromOurAlgorithm, indexFromLinearSearch);

View File

@ -37,7 +37,7 @@ public class RowColumnWiseSorted2dArrayBinarySearchTest {
}
@Test
public void rowColumnSorted2dArray_BinarySearchTestUpper() {
public void rowColumnSorted2dArrayBinarySearchTestUpper() {
Integer[][] arr = {
{10, 20, 30, 40},
{15, 25, 35, 45},
@ -52,7 +52,7 @@ public class RowColumnWiseSorted2dArrayBinarySearchTest {
}
@Test
public void rowColumnSorted2dArray_BinarySearchTestUpperSide() {
public void rowColumnSorted2dArrayBinarySearchTestUpperSide() {
Integer[][] arr = {
{10, 20, 30, 40},
{15, 25, 35, 45},
@ -67,7 +67,7 @@ public class RowColumnWiseSorted2dArrayBinarySearchTest {
}
@Test
public void rowColumnSorted2dArray_BinarySearchTestLower() {
public void rowColumnSorted2dArrayBinarySearchTestLower() {
Integer[][] arr = {
{10, 20, 30, 40},
{15, 25, 35, 45},
@ -82,7 +82,7 @@ public class RowColumnWiseSorted2dArrayBinarySearchTest {
}
@Test
public void rowColumnSorted2dArray_BinarySearchTestLowerSide() {
public void rowColumnSorted2dArrayBinarySearchTestLowerSide() {
Integer[][] arr = {
{10, 20, 30, 40},
{15, 25, 35, 45},
@ -97,7 +97,7 @@ public class RowColumnWiseSorted2dArrayBinarySearchTest {
}
@Test
public void rowColumnSorted2dArray_BinarySearchTestNotFound() {
public void rowColumnSorted2dArrayBinarySearchTestNotFound() {
Integer[][] arr = {
{10, 20, 30, 40},
{15, 25, 35, 45},

View File

@ -10,7 +10,7 @@ class BinaryInsertionSortTest {
@Test
// valid test case
public void BinaryInsertionSortTestNonDuplicate() {
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);
@ -18,7 +18,7 @@ class BinaryInsertionSortTest {
}
@Test
public void BinaryInsertionSortTestDuplicate() {
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);

View File

@ -11,7 +11,7 @@ public class DutchNationalFlagSortTest {
1 will be used as intended middle.
Partitions on the result array: [ smaller than 1 , equal 1, greater than 1]
*/
void DNFSTestOdd() {
void testOddDnfs() {
Integer[] integers = {1, 3, 1, 4, 0};
Integer[] integersResult = {0, 1, 1, 4, 3};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -24,7 +24,7 @@ public class DutchNationalFlagSortTest {
3 will be used as intended middle.
Partitions on the result array: [ smaller than 3 , equal 3, greater than 3]
*/
void DNFSTestEven() {
void testEvenDnfs() {
Integer[] integers = {8, 1, 3, 1, 4, 0};
Integer[] integersResult = {0, 1, 1, 3, 4, 8};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -37,7 +37,7 @@ public class DutchNationalFlagSortTest {
"b" will be used as intended middle.
Partitions on the result array: [ smaller than b , equal b, greater than b]
*/
void DNFSTestEvenStrings() {
void testEvenStringsDnfs() {
String[] strings = {"a", "d", "b", "s", "e", "e"};
String[] stringsResult = {"a", "b", "s", "e", "e", "d"};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -50,7 +50,7 @@ public class DutchNationalFlagSortTest {
"b" will be used as intended middle.
Partitions on the result array: [ smaller than b , equal b, greater than b]
*/
void DNFSTestOddStrings() {
void testOddStringsDnfs() {
String[] strings = {"a", "d", "b", "s", "e"};
String[] stringsResult = {"a", "b", "s", "e", "d"};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -63,7 +63,7 @@ public class DutchNationalFlagSortTest {
0 will be used as intended middle.
Partitions on the result array: [ smaller than 0 , equal 0, greater than 0]
*/
void DNFSTestOddMidGiven() {
void testOddMidGivenDnfs() {
Integer[] integers = {1, 3, 1, 4, 0};
Integer[] integersResult = {0, 1, 4, 3, 1};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -76,7 +76,7 @@ public class DutchNationalFlagSortTest {
4 will be used as intended middle.
Partitions on the result array: [ smaller than 4 , equal 4, greater than 4]
*/
void DNFSTestEvenMidGiven() {
void testEvenMidGivenDnfs() {
Integer[] integers = {8, 1, 3, 1, 4, 0};
Integer[] integersResult = {0, 1, 3, 1, 4, 8};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -89,7 +89,7 @@ public class DutchNationalFlagSortTest {
"s" will be used as intended middle.
Partitions on the result array: [ smaller than s , equal s, greater than s]
*/
void DNFSTestEvenStringsMidGiven() {
void testEvenStringsMidGivenDnfs() {
String[] strings = {"a", "d", "b", "s", "e", "e"};
String[] stringsResult = {"a", "d", "b", "e", "e", "s"};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();
@ -102,7 +102,7 @@ public class DutchNationalFlagSortTest {
"e" will be used as intended middle.
Partitions on the result array: [ smaller than e , equal e, greater than e]
*/
void DNFSTestOddStringsMidGiven() {
void testOddStringsMidGivenDnfs() {
String[] strings = {"a", "d", "b", "s", "e"};
String[] stringsResult = {"a", "d", "b", "e", "s"};
DutchNationalFlagSort dutchNationalFlagSort = new DutchNationalFlagSort();

View File

@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
public class IntrospectiveSortTest {
@Test
// valid test case
public void StrandSortNonDuplicateTest() {
public void strandSortNonDuplicateTest() {
Integer[] expectedArray = {1, 2, 3, 4, 5};
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
assertArrayEquals(expectedArray, actualList);
@ -16,7 +16,7 @@ public class IntrospectiveSortTest {
@Test
// valid test case
public void StrandSortDuplicateTest() {
public void strandSortDuplicateTest() {
Integer[] expectedArray = {2, 2, 2, 5, 7};
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
assertArrayEquals(expectedArray, actualList);
@ -24,7 +24,7 @@ public class IntrospectiveSortTest {
@Test
// valid test case
public void StrandSortEmptyTest() {
public void strandSortEmptyTest() {
Integer[] expectedArray = {};
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
assertArrayEquals(expectedArray, actualList);
@ -32,14 +32,14 @@ public class IntrospectiveSortTest {
@Test
// valid test case
public void StrandSortNullTest() {
public void strandSortNullTest() {
Integer[] expectedArray = null;
assertThrows(NullPointerException.class, () -> { new IntrospectiveSort().sort(expectedArray); });
}
@Test
// valid test case
public void StrandSortNegativeTest() {
public void strandSortNegativeTest() {
Integer[] expectedArray = {-1, -2, -3, -4, -5};
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
assertArrayEquals(expectedArray, actualList);
@ -47,7 +47,7 @@ public class IntrospectiveSortTest {
@Test
// valid test case
public void StrandSortNegativeAndPositiveTest() {
public void strandSortNegativeAndPositiveTest() {
Integer[] expectedArray = {-1, -2, -3, 4, 5};
Integer[] actualList = new IntrospectiveSort().sort(expectedArray);
assertArrayEquals(expectedArray, actualList);

View File

@ -8,7 +8,7 @@ class SelectionSortTest {
@Test
// valid test case
void IntegerArrTest() {
void integerArrTest() {
Integer[] arr = {4, 23, 6, 78, 1, 54, 231, 9, 12};
SelectionSort selectionSort = new SelectionSort();
@ -17,7 +17,7 @@ class SelectionSortTest {
@Test
// valid test case
void StringArrTest() {
void stringArrTest() {
String[] arr = {"c", "a", "e", "b", "d"};
SelectionSort selectionSort = new SelectionSort();

View File

@ -9,7 +9,7 @@ public class ShellSortTest {
private ShellSort shellSort = new ShellSort();
@Test
public void ShellSortEmptyArray() {
public void shellSortEmptyArray() {
Integer[] inputArray = {};
Integer[] outputArray = shellSort.sort(inputArray);
Integer[] expectedOutput = {};
@ -17,7 +17,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortSingleIntegerArray() {
public void shellSortSingleIntegerArray() {
Integer[] inputArray = {4};
Integer[] outputArray = shellSort.sort(inputArray);
Integer[] expectedOutput = {4};
@ -25,7 +25,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortSingleStringArray() {
public void shellSortSingleStringArray() {
String[] inputArray = {"s"};
String[] outputArray = shellSort.sort(inputArray);
String[] expectedOutput = {"s"};
@ -33,7 +33,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortNonDuplicateIntegerArray() {
public void shellSortNonDuplicateIntegerArray() {
Integer[] inputArray = {6, -1, 99, 27, -15, 23, -36};
Integer[] outputArray = shellSort.sort(inputArray);
Integer[] expectedOutput = {-36, -15, -1, 6, 23, 27, 99};
@ -41,7 +41,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortDuplicateIntegerArray() {
public void shellSortDuplicateIntegerArray() {
Integer[] inputArray = {6, -1, 27, -15, 23, 27, -36, 23};
Integer[] outputArray = shellSort.sort(inputArray);
Integer[] expectedOutput = {-36, -15, -1, 6, 23, 23, 27, 27};
@ -49,7 +49,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortNonDuplicateStringArray() {
public void shellSortNonDuplicateStringArray() {
String[] inputArray = {"s", "b", "k", "a", "d", "c", "h"};
String[] outputArray = shellSort.sort(inputArray);
String[] expectedOutput = {"a", "b", "c", "d", "h", "k", "s"};
@ -57,7 +57,7 @@ public class ShellSortTest {
}
@Test
public void ShellSortDuplicateStringArray() {
public void shellSortDuplicateStringArray() {
String[] inputArray = {"s", "b", "d", "a", "d", "c", "h", "b"};
String[] outputArray = shellSort.sort(inputArray);
String[] expectedOutput = {"a", "b", "b", "c", "d", "d", "h", "s"};

View File

@ -10,7 +10,7 @@ class StrandSortTest {
@Test
// valid test case
public void StrandSortNonDuplicateTest() {
public void strandSortNonDuplicateTest() {
int[] expectedArray = {1, 2, 3, 4, 5};
LinkedList<Integer> actualList = StrandSort.strandSort(new LinkedList<Integer>(Arrays.asList(3, 1, 2, 4, 5)));
int[] actualArray = new int[actualList.size()];
@ -22,7 +22,7 @@ class StrandSortTest {
@Test
// valid test case
public void StrandSortDuplicateTest() {
public void strandSortDuplicateTest() {
int[] expectedArray = {2, 2, 2, 5, 7};
LinkedList<Integer> actualList = StrandSort.strandSort(new LinkedList<Integer>(Arrays.asList(7, 2, 2, 2, 5)));
int[] actualArray = new int[actualList.size()];

View File

@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test;
public class WiggleSortTest {
@Test
void WiggleTestNumbersEven() {
void wiggleTestNumbersEven() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {1, 2, 3, 4};
Integer[] result = {1, 4, 2, 3};
@ -17,7 +17,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestNumbersOdd() {
void wiggleTestNumbersOdd() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {1, 2, 3, 4, 5};
Integer[] result = {3, 5, 1, 4, 2};
@ -26,7 +26,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestNumbersOddDuplicates() {
void wiggleTestNumbersOddDuplicates() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {7, 2, 2, 2, 5};
Integer[] result = {2, 7, 2, 5, 2};
@ -35,7 +35,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestNumbersOddMultipleDuplicates() {
void wiggleTestNumbersOddMultipleDuplicates() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {1, 1, 2, 2, 5};
Integer[] result = {2, 5, 1, 2, 1};
@ -44,7 +44,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestNumbersEvenMultipleDuplicates() {
void wiggleTestNumbersEvenMultipleDuplicates() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {1, 1, 2, 2, 2, 5};
Integer[] result = {2, 5, 1, 2, 1, 2};
@ -54,7 +54,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestNumbersEvenDuplicates() {
void wiggleTestNumbersEvenDuplicates() {
WiggleSort wiggleSort = new WiggleSort();
Integer[] values = {1, 2, 4, 4};
Integer[] result = {1, 4, 2, 4};
@ -63,7 +63,7 @@ public class WiggleSortTest {
}
@Test
void WiggleTestStrings() {
void wiggleTestStrings() {
WiggleSort wiggleSort = new WiggleSort();
String[] values = {"a", "b", "d", "c"};
String[] result = {"a", "d", "b", "c"};

View File

@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test;
public class ReverseStringTest {
@Test
public void ReverseStringTest() {
public void testReverseString() {
String input1 = "Hello World";
String input2 = "helloworld";
String input3 = "123456789";