diff --git a/spotbugs-exclude.xml b/spotbugs-exclude.xml
index 8c51fcf42b2e..1390387bacdf 100644
--- a/spotbugs-exclude.xml
+++ b/spotbugs-exclude.xml
@@ -210,9 +210,6 @@
-
-
-
diff --git a/src/test/java/com/thealgorithms/backtracking/PermutationTest.java b/src/test/java/com/thealgorithms/backtracking/PermutationTest.java
index 76a714829109..54747e5e73a1 100644
--- a/src/test/java/com/thealgorithms/backtracking/PermutationTest.java
+++ b/src/test/java/com/thealgorithms/backtracking/PermutationTest.java
@@ -12,13 +12,13 @@ public class PermutationTest {
@Test
void testNoElement() {
List result = Permutation.permutation(new Integer[] {});
- assertEquals(result.get(0).length, 0);
+ assertEquals(0, result.get(0).length);
}
@Test
void testSingleElement() {
List result = Permutation.permutation(new Integer[] {1});
- assertEquals(result.get(0)[0], 1);
+ assertEquals(1, result.get(0)[0]);
}
@Test
diff --git a/src/test/java/com/thealgorithms/ciphers/ECCTest.java b/src/test/java/com/thealgorithms/ciphers/ECCTest.java
index 701f801af1c8..b78ba51f7c3e 100644
--- a/src/test/java/com/thealgorithms/ciphers/ECCTest.java
+++ b/src/test/java/com/thealgorithms/ciphers/ECCTest.java
@@ -37,7 +37,7 @@ void testEncrypt() {
System.out.println("Base Point G: " + curve.getBasePoint());
// Verify that the ciphertext is not empty
- assertEquals(cipherText.length, 2); // Check if the ciphertext contains two points (R and S)
+ assertEquals(2, cipherText.length); // Check if the ciphertext contains two points (R and S)
// Output the encrypted coordinate points
System.out.println("Encrypted Points:");
diff --git a/src/test/java/com/thealgorithms/datastructures/hashmap/hashing/MapTest.java b/src/test/java/com/thealgorithms/datastructures/hashmap/hashing/MapTest.java
index 44551a8adac6..ef7739a2e8a9 100644
--- a/src/test/java/com/thealgorithms/datastructures/hashmap/hashing/MapTest.java
+++ b/src/test/java/com/thealgorithms/datastructures/hashmap/hashing/MapTest.java
@@ -81,19 +81,19 @@ void containsTest() {
@Test
void sizeTest() {
Map map = getMap();
- assertEquals(map.size(), 0);
+ assertEquals(0, map.size());
for (int i = -100; i < 100; i++) {
map.put(i, String.valueOf(i));
}
- assertEquals(map.size(), 200);
+ assertEquals(200, map.size());
for (int i = -50; i < 50; i++) {
map.delete(i);
}
- assertEquals(map.size(), 100);
+ assertEquals(100, map.size());
}
@Test
diff --git a/src/test/java/com/thealgorithms/datastructures/queues/PriorityQueuesTest.java b/src/test/java/com/thealgorithms/datastructures/queues/PriorityQueuesTest.java
index e97fe091c556..3bb8bbabb761 100644
--- a/src/test/java/com/thealgorithms/datastructures/queues/PriorityQueuesTest.java
+++ b/src/test/java/com/thealgorithms/datastructures/queues/PriorityQueuesTest.java
@@ -9,14 +9,14 @@ class PriorityQueuesTest {
void testPQInsertion() {
PriorityQueue myQueue = new PriorityQueue(4);
myQueue.insert(2);
- Assertions.assertEquals(myQueue.peek(), 2);
+ Assertions.assertEquals(2, myQueue.peek());
myQueue.insert(5);
myQueue.insert(3);
- Assertions.assertEquals(myQueue.peek(), 5);
+ Assertions.assertEquals(5, myQueue.peek());
myQueue.insert(10);
- Assertions.assertEquals(myQueue.peek(), 10);
+ Assertions.assertEquals(10, myQueue.peek());
}
@Test
@@ -28,32 +28,32 @@ void testPQDeletion() {
myQueue.insert(10);
myQueue.remove();
- Assertions.assertEquals(myQueue.peek(), 5);
+ Assertions.assertEquals(5, myQueue.peek());
myQueue.remove();
myQueue.remove();
- Assertions.assertEquals(myQueue.peek(), 2);
+ Assertions.assertEquals(2, myQueue.peek());
}
@Test
void testPQExtra() {
PriorityQueue myQueue = new PriorityQueue(4);
- Assertions.assertEquals(myQueue.isEmpty(), true);
- Assertions.assertEquals(myQueue.isFull(), false);
+ Assertions.assertTrue(myQueue.isEmpty());
+ Assertions.assertFalse(myQueue.isFull());
myQueue.insert(2);
myQueue.insert(5);
- Assertions.assertEquals(myQueue.isFull(), false);
+ Assertions.assertFalse(myQueue.isFull());
myQueue.insert(3);
myQueue.insert(10);
- Assertions.assertEquals(myQueue.isEmpty(), false);
- Assertions.assertEquals(myQueue.isFull(), true);
+ Assertions.assertFalse(myQueue.isEmpty());
+ Assertions.assertTrue(myQueue.isFull());
myQueue.remove();
- Assertions.assertEquals(myQueue.getSize(), 3);
- Assertions.assertEquals(myQueue.peek(), 5);
+ Assertions.assertEquals(3, myQueue.getSize());
+ Assertions.assertEquals(5, myQueue.peek());
myQueue.remove();
myQueue.remove();
- Assertions.assertEquals(myQueue.peek(), 2);
- Assertions.assertEquals(myQueue.getSize(), 1);
+ Assertions.assertEquals(2, myQueue.peek());
+ Assertions.assertEquals(1, myQueue.getSize());
}
@Test
diff --git a/src/test/java/com/thealgorithms/io/BufferedReaderTest.java b/src/test/java/com/thealgorithms/io/BufferedReaderTest.java
index 891c3066058e..088e86f8f7c5 100644
--- a/src/test/java/com/thealgorithms/io/BufferedReaderTest.java
+++ b/src/test/java/com/thealgorithms/io/BufferedReaderTest.java
@@ -17,15 +17,15 @@ public void testPeeks() throws IOException {
BufferedReader reader = new BufferedReader(input);
// read the first letter
- assertEquals(reader.read(), 'H');
+ assertEquals('H', reader.read());
len--;
- assertEquals(reader.available(), len);
+ assertEquals(len, reader.available());
// position: H[e]llo!\nWorld!
// reader.read() will be == 'e'
- assertEquals(reader.peek(1), 'l');
- assertEquals(reader.peek(2), 'l'); // second l
- assertEquals(reader.peek(3), 'o');
+ assertEquals('l', reader.peek(1));
+ assertEquals('l', reader.peek(2)); // second l
+ assertEquals('o', reader.peek(3));
}
@Test
@@ -38,21 +38,21 @@ public void testMixes() throws IOException {
BufferedReader reader = new BufferedReader(input);
// read the first letter
- assertEquals(reader.read(), 'H'); // first letter
+ assertEquals('H', reader.read()); // first letter
len--;
- assertEquals(reader.peek(1), 'l'); // third later (second letter after 'H')
- assertEquals(reader.read(), 'e'); // second letter
+ assertEquals('l', reader.peek(1)); // third later (second letter after 'H')
+ assertEquals('e', reader.read()); // second letter
len--;
- assertEquals(reader.available(), len);
+ assertEquals(len, reader.available());
// position: H[e]llo!\nWorld!
- assertEquals(reader.peek(2), 'o'); // second l
- assertEquals(reader.peek(3), '!');
- assertEquals(reader.peek(4), '\n');
+ assertEquals('o', reader.peek(2)); // second l
+ assertEquals('!', reader.peek(3));
+ assertEquals('\n', reader.peek(4));
- assertEquals(reader.read(), 'l'); // third letter
- assertEquals(reader.peek(1), 'o'); // fourth letter
+ assertEquals('l', reader.read()); // third letter
+ assertEquals('o', reader.peek(1)); // fourth letter
for (int i = 0; i < 6; i++) {
reader.read();
@@ -74,23 +74,23 @@ public void testBlockPractical() throws IOException {
ByteArrayInputStream input = new ByteArrayInputStream(bytes);
BufferedReader reader = new BufferedReader(input);
- assertEquals(reader.peek(), 'H');
- assertEquals(reader.read(), '!'); // read the first letter
+ assertEquals('H', reader.peek());
+ assertEquals('!', reader.read()); // read the first letter
len--;
// this only reads the next 5 bytes (Hello) because
// the default buffer size = 5
- assertEquals(new String(reader.readBlock()), "Hello");
+ assertEquals("Hello", new String(reader.readBlock()));
len -= 5;
assertEquals(reader.available(), len);
// maybe kind of a practical demonstration / use case
if (reader.read() == '\n') {
- assertEquals(reader.read(), 'W');
- assertEquals(reader.read(), 'o');
+ assertEquals('W', reader.read());
+ assertEquals('o', reader.read());
// the rest of the blocks
- assertEquals(new String(reader.readBlock()), "rld!");
+ assertEquals("rld!", new String(reader.readBlock()));
} else {
// should not reach
throw new IOException("Something not right");
diff --git a/src/test/java/com/thealgorithms/maths/DistanceFormulaTest.java b/src/test/java/com/thealgorithms/maths/DistanceFormulaTest.java
index 3a14b80dd4f9..66f3b7b03938 100644
--- a/src/test/java/com/thealgorithms/maths/DistanceFormulaTest.java
+++ b/src/test/java/com/thealgorithms/maths/DistanceFormulaTest.java
@@ -9,78 +9,78 @@ public class DistanceFormulaTest {
@Test
void euclideanTest1() {
- Assertions.assertEquals(DistanceFormula.euclideanDistance(1, 1, 2, 2), 1.4142135623730951);
+ Assertions.assertEquals(1.4142135623730951, DistanceFormula.euclideanDistance(1, 1, 2, 2));
}
@Test
void euclideanTest2() {
- Assertions.assertEquals(DistanceFormula.euclideanDistance(1, 3, 8, 0), 7.0710678118654755);
+ Assertions.assertEquals(7.0710678118654755, DistanceFormula.euclideanDistance(1, 3, 8, 0));
}
@Test
void euclideanTest3() {
- Assertions.assertEquals(DistanceFormula.euclideanDistance(2.4, 9.1, 55.1, 100), 110.91911467371168);
+ Assertions.assertEquals(110.91911467371168, DistanceFormula.euclideanDistance(2.4, 9.1, 55.1, 100));
}
@Test
void euclideanTest4() {
- Assertions.assertEquals(DistanceFormula.euclideanDistance(1000, 13, 20000, 84), 19022.067605809836);
+ Assertions.assertEquals(19022.067605809836, DistanceFormula.euclideanDistance(1000, 13, 20000, 84));
}
@Test
public void manhattantest1() {
- assertEquals(DistanceFormula.manhattanDistance(1, 2, 3, 4), 4);
+ assertEquals(4, DistanceFormula.manhattanDistance(1, 2, 3, 4));
}
@Test
public void manhattantest2() {
- assertEquals(DistanceFormula.manhattanDistance(6.5, 8.4, 20.1, 13.6), 18.8);
+ assertEquals(18.8, DistanceFormula.manhattanDistance(6.5, 8.4, 20.1, 13.6));
}
@Test
public void manhattanTest3() {
- assertEquals(DistanceFormula.manhattanDistance(10.112, 50, 8, 25.67), 26.442);
+ assertEquals(26.442, DistanceFormula.manhattanDistance(10.112, 50, 8, 25.67));
}
@Test
public void hammingTest1() {
int[] array1 = {1, 1, 1, 1};
int[] array2 = {0, 0, 0, 0};
- assertEquals(DistanceFormula.hammingDistance(array1, array2), 4);
+ assertEquals(4, DistanceFormula.hammingDistance(array1, array2));
}
@Test
public void hammingTest2() {
int[] array1 = {1, 1, 1, 1};
int[] array2 = {1, 1, 1, 1};
- assertEquals(DistanceFormula.hammingDistance(array1, array2), 0);
+ assertEquals(0, DistanceFormula.hammingDistance(array1, array2));
}
@Test
public void hammingTest3() {
int[] array1 = {1, 0, 0, 1, 1, 0, 1, 1, 0};
int[] array2 = {0, 1, 0, 0, 1, 1, 1, 0, 0};
- assertEquals(DistanceFormula.hammingDistance(array1, array2), 5);
+ assertEquals(5, DistanceFormula.hammingDistance(array1, array2));
}
@Test
public void minkowskiTest1() {
double[] array1 = {1, 3, 8, 5};
double[] array2 = {4, 2, 6, 9};
- assertEquals(DistanceFormula.minkowskiDistance(array1, array2, 1), 10);
+ assertEquals(10, DistanceFormula.minkowskiDistance(array1, array2, 1));
}
@Test
public void minkowskiTest2() {
double[] array1 = {1, 3, 8, 5};
double[] array2 = {4, 2, 6, 9};
- assertEquals(DistanceFormula.minkowskiDistance(array1, array2, 2), 5.477225575051661);
+ assertEquals(5.477225575051661, DistanceFormula.minkowskiDistance(array1, array2, 2));
}
@Test
public void minkowskiTest3() {
double[] array1 = {1, 3, 8, 5};
double[] array2 = {4, 2, 6, 9};
- assertEquals(DistanceFormula.minkowskiDistance(array1, array2, 3), 4.641588833612778);
+ assertEquals(4.641588833612778, DistanceFormula.minkowskiDistance(array1, array2, 3));
}
}
diff --git a/src/test/java/com/thealgorithms/maths/FactorialTest.java b/src/test/java/com/thealgorithms/maths/FactorialTest.java
index b38dc45589ee..3ff7097b8113 100644
--- a/src/test/java/com/thealgorithms/maths/FactorialTest.java
+++ b/src/test/java/com/thealgorithms/maths/FactorialTest.java
@@ -11,7 +11,7 @@ public class FactorialTest {
@Test
public void testWhenInvalidInoutProvidedShouldThrowException() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> Factorial.factorial(-1));
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ assertEquals(EXCEPTION_MESSAGE, exception.getMessage());
}
@Test
diff --git a/src/test/java/com/thealgorithms/maths/NthUglyNumberTest.java b/src/test/java/com/thealgorithms/maths/NthUglyNumberTest.java
index 3fe58dadf8a5..1ee437b190c5 100644
--- a/src/test/java/com/thealgorithms/maths/NthUglyNumberTest.java
+++ b/src/test/java/com/thealgorithms/maths/NthUglyNumberTest.java
@@ -48,22 +48,22 @@ public void testGetWithSameObject() {
var uglyNumbers = new NthUglyNumber(new int[] {7, 2, 5, 3});
for (final var tc : testCases.entrySet()) {
- assertEquals(uglyNumbers.get(tc.getKey()), tc.getValue());
+ assertEquals(tc.getValue(), uglyNumbers.get(tc.getKey()));
}
- assertEquals(uglyNumbers.get(999), 385875);
+ assertEquals(385875, uglyNumbers.get(999));
}
@Test
public void testGetWithBase1() {
var uglyNumbers = new NthUglyNumber(new int[] {1});
- assertEquals(uglyNumbers.get(10), 1);
+ assertEquals(1, uglyNumbers.get(10));
}
@Test
public void testGetWithBase2() {
var uglyNumbers = new NthUglyNumber(new int[] {2});
- assertEquals(uglyNumbers.get(5), 32);
+ assertEquals(32, uglyNumbers.get(5));
}
@Test
diff --git a/src/test/java/com/thealgorithms/maths/PalindromeNumberTest.java b/src/test/java/com/thealgorithms/maths/PalindromeNumberTest.java
index a70100c0b913..4e4bd85d07b5 100644
--- a/src/test/java/com/thealgorithms/maths/PalindromeNumberTest.java
+++ b/src/test/java/com/thealgorithms/maths/PalindromeNumberTest.java
@@ -25,6 +25,6 @@ public void testNumbersAreNotPalindromes() {
@Test
public void testIfNegativeInputThenExceptionExpected() {
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> PalindromeNumber.isPalindrome(-1));
- Assertions.assertEquals(exception.getMessage(), "Input parameter must not be negative!");
+ Assertions.assertEquals("Input parameter must not be negative!", exception.getMessage());
}
}
diff --git a/src/test/java/com/thealgorithms/maths/ParseIntegerTest.java b/src/test/java/com/thealgorithms/maths/ParseIntegerTest.java
index 7649e21eb231..a9b78be88042 100644
--- a/src/test/java/com/thealgorithms/maths/ParseIntegerTest.java
+++ b/src/test/java/com/thealgorithms/maths/ParseIntegerTest.java
@@ -14,13 +14,13 @@ public class ParseIntegerTest {
@Test
public void testNullInput() {
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ParseInteger.parseInt(null));
- Assertions.assertEquals(exception.getMessage(), NULL_PARAMETER_MESSAGE);
+ Assertions.assertEquals(NULL_PARAMETER_MESSAGE, exception.getMessage());
}
@Test
public void testEmptyInput() {
IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> ParseInteger.parseInt(""));
- Assertions.assertEquals(exception.getMessage(), EMPTY_PARAMETER_MESSAGE);
+ Assertions.assertEquals(EMPTY_PARAMETER_MESSAGE, exception.getMessage());
}
@Test
diff --git a/src/test/java/com/thealgorithms/maths/QuadraticEquationSolverTest.java b/src/test/java/com/thealgorithms/maths/QuadraticEquationSolverTest.java
index a2046511ddf5..a6552d56783c 100644
--- a/src/test/java/com/thealgorithms/maths/QuadraticEquationSolverTest.java
+++ b/src/test/java/com/thealgorithms/maths/QuadraticEquationSolverTest.java
@@ -14,10 +14,10 @@ public void testSolveEquationRealRoots() {
double c = 1.9;
ComplexNumber[] roots = quadraticEquationSolver.solveEquation(a, b, c);
- Assertions.assertEquals(roots.length, 2);
- Assertions.assertEquals(roots[0].real, -0.27810465435684306);
+ Assertions.assertEquals(2, roots.length, 2);
+ Assertions.assertEquals(-0.27810465435684306, roots[0].real);
Assertions.assertNull(roots[0].imaginary);
- Assertions.assertEquals(roots[1].real, -1.6266572504050616);
+ Assertions.assertEquals(-1.6266572504050616, roots[1].real);
Assertions.assertNull(roots[1].imaginary);
}
@@ -29,8 +29,8 @@ public void testSolveEquationEqualRoots() {
double c = 1;
ComplexNumber[] roots = quadraticEquationSolver.solveEquation(a, b, c);
- Assertions.assertEquals(roots.length, 1);
- Assertions.assertEquals(roots[0].real, -1);
+ Assertions.assertEquals(1, roots.length);
+ Assertions.assertEquals(-1, roots[0].real);
}
@Test
@@ -41,10 +41,10 @@ public void testSolveEquationComplexRoots() {
double c = 5.6;
ComplexNumber[] roots = quadraticEquationSolver.solveEquation(a, b, c);
- Assertions.assertEquals(roots.length, 2);
- Assertions.assertEquals(roots[0].real, -0.8695652173913044);
- Assertions.assertEquals(roots[0].imaginary, 1.2956229935435948);
- Assertions.assertEquals(roots[1].real, -0.8695652173913044);
- Assertions.assertEquals(roots[1].imaginary, -1.2956229935435948);
+ Assertions.assertEquals(2, roots.length);
+ Assertions.assertEquals(-0.8695652173913044, roots[0].real);
+ Assertions.assertEquals(1.2956229935435948, roots[0].imaginary);
+ Assertions.assertEquals(-0.8695652173913044, roots[1].real);
+ Assertions.assertEquals(-1.2956229935435948, roots[1].imaginary);
}
}
diff --git a/src/test/java/com/thealgorithms/maths/SecondMinMaxTest.java b/src/test/java/com/thealgorithms/maths/SecondMinMaxTest.java
index c744614e5cfa..c5d47f2213a9 100644
--- a/src/test/java/com/thealgorithms/maths/SecondMinMaxTest.java
+++ b/src/test/java/com/thealgorithms/maths/SecondMinMaxTest.java
@@ -29,19 +29,19 @@ public TestCase(final int[] inInputArray, final int inSecondMin, final int inSec
@Test
public void testForEmptyInputArray() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> SecondMinMax.findSecondMin(new int[] {}));
- assertEquals(exception.getMessage(), EXP_MSG_ARR_LEN_LESS_2);
+ assertEquals(EXP_MSG_ARR_LEN_LESS_2, exception.getMessage());
}
@Test
public void testForArrayWithSingleElement() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> SecondMinMax.findSecondMax(new int[] {1}));
- assertEquals(exception.getMessage(), EXP_MSG_ARR_LEN_LESS_2);
+ assertEquals(EXP_MSG_ARR_LEN_LESS_2, exception.getMessage());
}
@Test
public void testForArrayWithSameElements() {
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> SecondMinMax.findSecondMin(new int[] {1, 1, 1, 1}));
- assertEquals(exception.getMessage(), EXP_MSG_ARR_SAME_ELE);
+ assertEquals(EXP_MSG_ARR_SAME_ELE, exception.getMessage());
}
@ParameterizedTest
diff --git a/src/test/java/com/thealgorithms/maths/StandardDeviationTest.java b/src/test/java/com/thealgorithms/maths/StandardDeviationTest.java
index 2c10d2d14f3e..4716d389a4ca 100644
--- a/src/test/java/com/thealgorithms/maths/StandardDeviationTest.java
+++ b/src/test/java/com/thealgorithms/maths/StandardDeviationTest.java
@@ -8,19 +8,19 @@ public class StandardDeviationTest {
@Test
void test1() {
double[] t1 = new double[] {1, 1, 1, 1, 1};
- Assertions.assertEquals(StandardDeviation.stdDev(t1), 0.0);
+ Assertions.assertEquals(0.0, StandardDeviation.stdDev(t1));
}
@Test
void test2() {
double[] t2 = new double[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- Assertions.assertEquals(StandardDeviation.stdDev(t2), 2.8722813232690143);
+ Assertions.assertEquals(2.8722813232690143, StandardDeviation.stdDev(t2));
}
@Test
void test3() {
double[] t3 = new double[] {1.1, 8.5, 20.3, 2.4, 6.2};
- Assertions.assertEquals(StandardDeviation.stdDev(t3), 6.8308125431752265);
+ Assertions.assertEquals(6.8308125431752265, StandardDeviation.stdDev(t3));
}
@Test
@@ -32,6 +32,6 @@ void test4() {
100.00045,
56.7,
};
- Assertions.assertEquals(StandardDeviation.stdDev(t4), 38.506117353865775);
+ Assertions.assertEquals(38.506117353865775, StandardDeviation.stdDev(t4));
}
}
diff --git a/src/test/java/com/thealgorithms/maths/StandardScoreTest.java b/src/test/java/com/thealgorithms/maths/StandardScoreTest.java
index 436b1fd011c6..6858b87ad2c6 100644
--- a/src/test/java/com/thealgorithms/maths/StandardScoreTest.java
+++ b/src/test/java/com/thealgorithms/maths/StandardScoreTest.java
@@ -7,21 +7,21 @@ public class StandardScoreTest {
@Test
void test1() {
- Assertions.assertEquals(StandardScore.zScore(2, 0, 5), 0.4);
+ Assertions.assertEquals(0.4, StandardScore.zScore(2, 0, 5));
}
@Test
void test2() {
- Assertions.assertEquals(StandardScore.zScore(1, 1, 1), 0.0);
+ Assertions.assertEquals(0.0, StandardScore.zScore(1, 1, 1));
}
@Test
void test3() {
- Assertions.assertEquals(StandardScore.zScore(2.5, 1.8, 0.7), 1.0);
+ Assertions.assertEquals(1.0, StandardScore.zScore(2.5, 1.8, 0.7));
}
@Test
void test4() {
- Assertions.assertEquals(StandardScore.zScore(8.9, 3, 4.2), 1.4047619047619049);
+ Assertions.assertEquals(1.4047619047619049, StandardScore.zScore(8.9, 3, 4.2));
}
}
diff --git a/src/test/java/com/thealgorithms/maths/VolumeTest.java b/src/test/java/com/thealgorithms/maths/VolumeTest.java
index 1ba0aec47cef..af882eef7563 100644
--- a/src/test/java/com/thealgorithms/maths/VolumeTest.java
+++ b/src/test/java/com/thealgorithms/maths/VolumeTest.java
@@ -10,30 +10,30 @@ public class VolumeTest {
public void volume() {
/* test cube */
- assertEquals(Volume.volumeCube(7), 343.0);
+ assertEquals(343.0, Volume.volumeCube(7));
/* test cuboid */
- assertEquals(Volume.volumeCuboid(2, 5, 7), 70.0);
+ assertEquals(70.0, Volume.volumeCuboid(2, 5, 7));
/* test sphere */
- assertEquals(Volume.volumeSphere(7), 1436.7550402417319);
+ assertEquals(1436.7550402417319, Volume.volumeSphere(7));
/* test cylinder */
- assertEquals(Volume.volumeCylinder(3, 7), 197.92033717615698);
+ assertEquals(197.92033717615698, Volume.volumeCylinder(3, 7));
/* test hemisphere */
- assertEquals(Volume.volumeHemisphere(7), 718.3775201208659);
+ assertEquals(718.3775201208659, Volume.volumeHemisphere(7));
/* test cone */
- assertEquals(Volume.volumeCone(3, 7), 65.97344572538566);
+ assertEquals(65.97344572538566, Volume.volumeCone(3, 7));
/* test prism */
- assertEquals(Volume.volumePrism(10, 2), 20.0);
+ assertEquals(20.0, Volume.volumePrism(10, 2));
/* test pyramid */
- assertEquals(Volume.volumePyramid(10, 3), 10.0);
+ assertEquals(10.0, Volume.volumePyramid(10, 3));
/* test frustum */
- assertEquals(Volume.volumeFrustumOfCone(3, 5, 7), 359.188760060433);
+ assertEquals(359.188760060433, Volume.volumeFrustumOfCone(3, 5, 7));
}
}
diff --git a/src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java b/src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java
index f41953035846..c4a74af0ba8b 100644
--- a/src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java
+++ b/src/test/java/com/thealgorithms/misc/MedianOfRunningArrayTest.java
@@ -17,7 +17,7 @@ public class MedianOfRunningArrayTest {
public void testWhenInvalidInoutProvidedShouldThrowException() {
var stream = new MedianOfRunningArrayInteger();
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, stream::getMedian);
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ assertEquals(EXCEPTION_MESSAGE, exception.getMessage());
}
@Test
diff --git a/src/test/java/com/thealgorithms/searches/BinarySearch2dArrayTest.java b/src/test/java/com/thealgorithms/searches/BinarySearch2dArrayTest.java
index 18f0afc6a0a6..dec2c86de9c7 100644
--- a/src/test/java/com/thealgorithms/searches/BinarySearch2dArrayTest.java
+++ b/src/test/java/com/thealgorithms/searches/BinarySearch2dArrayTest.java
@@ -117,7 +117,7 @@ public void binarySearch2dArrayTestTargetInMiddle() {
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);
+ assertEquals(target, arr[arr.length / 2][arr[0].length / 2]);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(1, ans[0]);
@@ -135,8 +135,8 @@ public void binarySearch2dArrayTestTargetAboveMiddleRowInMiddleColumn() {
// Assert that the requirement, that he target is in the middle column,
// 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);
+ assertEquals(0, arr[0].length % 2);
+ assertEquals(target, arr[arr.length / 2 - 1][arr[0].length / 2]);
int[] ans = BinarySearch2dArray.binarySearch(arr, target);
System.out.println(Arrays.toString(ans));
assertEquals(0, ans[0]);
diff --git a/src/test/java/com/thealgorithms/searches/KMPSearchTest.java b/src/test/java/com/thealgorithms/searches/KMPSearchTest.java
index cb804ac6a6a3..216c5fcd7d2c 100644
--- a/src/test/java/com/thealgorithms/searches/KMPSearchTest.java
+++ b/src/test/java/com/thealgorithms/searches/KMPSearchTest.java
@@ -14,7 +14,7 @@ public void kmpSearchTestLast() {
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
- assertEquals(value, 10);
+ assertEquals(10, value);
}
@Test
@@ -25,7 +25,7 @@ public void kmpSearchTestFront() {
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
- assertEquals(value, 0);
+ assertEquals(0, value);
}
@Test
@@ -36,7 +36,7 @@ public void kmpSearchTestMiddle() {
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
- assertEquals(value, 4);
+ assertEquals(4, value);
}
@Test
@@ -47,7 +47,7 @@ public void kmpSearchTestNotFound() {
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
- assertEquals(value, 4);
+ assertEquals(4, value);
}
@Test
@@ -58,6 +58,6 @@ public void kmpSearchTest4() {
KMPSearch kmpSearch = new KMPSearch();
int value = kmpSearch.kmpSearch(pat, txt);
System.out.println(value);
- assertEquals(value, -1);
+ assertEquals(-1, value);
}
}
diff --git a/src/test/java/com/thealgorithms/searches/QuickSelectTest.java b/src/test/java/com/thealgorithms/searches/QuickSelectTest.java
index cf160b0ff4b5..4c96be76861a 100644
--- a/src/test/java/com/thealgorithms/searches/QuickSelectTest.java
+++ b/src/test/java/com/thealgorithms/searches/QuickSelectTest.java
@@ -172,7 +172,7 @@ void quickSelect70thPercentileOfManyElements() {
void quickSelectMedianOfThreeCharacters() {
List elements = Arrays.asList('X', 'Z', 'Y');
char actual = QuickSelect.select(elements, 1);
- assertEquals(actual, 'Y');
+ assertEquals('Y', actual);
}
@Test
diff --git a/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java b/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java
index d5588b2b968e..e19f5b928263 100644
--- a/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java
+++ b/src/test/java/com/thealgorithms/sorts/TopologicalSortTest.java
@@ -58,7 +58,7 @@ public void failureTest() {
Exception exception = assertThrows(RuntimeException.class, () -> TopologicalSort.sort(graph));
String expected = "This graph contains a cycle. No linear ordering is possible. "
+ "Back edge: 6 -> 2";
- assertEquals(exception.getMessage(), expected);
+ assertEquals(expected, exception.getMessage());
}
@Test
void testEmptyGraph() {
diff --git a/src/test/java/com/thealgorithms/strings/WordLadderTest.java b/src/test/java/com/thealgorithms/strings/WordLadderTest.java
index 221953411da7..c029940abfb0 100644
--- a/src/test/java/com/thealgorithms/strings/WordLadderTest.java
+++ b/src/test/java/com/thealgorithms/strings/WordLadderTest.java
@@ -24,7 +24,7 @@ public class WordLadderTest {
public void testWordLadder() {
List wordList1 = Arrays.asList("hot", "dot", "dog", "lot", "log", "cog");
- assertEquals(WordLadder.ladderLength("hit", "cog", wordList1), 5);
+ assertEquals(5, WordLadder.ladderLength("hit", "cog", wordList1));
}
/**
@@ -39,7 +39,7 @@ public void testWordLadder() {
public void testWordLadder2() {
List wordList2 = Arrays.asList("hot", "dot", "dog", "lot", "log");
- assertEquals(WordLadder.ladderLength("hit", "cog", wordList2), 0);
+ assertEquals(0, WordLadder.ladderLength("hit", "cog", wordList2));
}
/**
@@ -54,7 +54,7 @@ public void testWordLadder2() {
public void testWordLadder3() {
List wordList3 = emptyList();
- assertEquals(WordLadder.ladderLength("hit", "cog", wordList3), 0);
+ assertEquals(0, WordLadder.ladderLength("hit", "cog", wordList3));
}
@ParameterizedTest
diff --git a/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java b/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java
index 2cbbfe3d2dd8..9bf118c9b844 100644
--- a/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java
+++ b/src/test/java/com/thealgorithms/strings/zigZagPattern/ZigZagPatternTest.java
@@ -9,8 +9,8 @@ public class ZigZagPatternTest {
public void testZigZagPattern() {
String input1 = "HelloWorldFromJava";
String input2 = "javaIsAProgrammingLanguage";
- Assertions.assertEquals(ZigZagPattern.encode(input1, 4), "HooeWrrmalolFJvlda");
- Assertions.assertEquals(ZigZagPattern.encode(input2, 4), "jAaLgasPrmgaaevIrgmnnuaoig");
+ Assertions.assertEquals("HooeWrrmalolFJvlda", ZigZagPattern.encode(input1, 4));
+ Assertions.assertEquals("jAaLgasPrmgaaevIrgmnnuaoig", ZigZagPattern.encode(input2, 4));
// Edge cases
Assertions.assertEquals("ABC", ZigZagPattern.encode("ABC", 1)); // Single row
Assertions.assertEquals("A", ZigZagPattern.encode("A", 2)); // numRows > length of string