11package com .thealgorithms .matrix ;
22
3- import org .junit .jupiter .api .Test ;
4- import static org .junit .jupiter .api .Assertions .assertThrows ;
53import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertThrows ;
65import static org .junit .jupiter .api .Assertions .assertTrue ;
76
7+ import org .junit .jupiter .api .Test ;
8+
9+
810public class MatrixMultiplicationTest {
911
1012 private static final double EPSILON = 1e-9 ; // for floating point comparison
@@ -32,24 +34,21 @@ void testMultiply3by2and2by1() {
3234 @ Test
3335 void testNullMatrixA () {
3436 double [][] b = {{1 , 2 }, {3 , 4 }};
35- assertThrows (IllegalArgumentException .class ,
36- () -> MatrixMultiplication .multiply (null , b ));
37+ assertThrows (IllegalArgumentException .class , () -> MatrixMultiplication .multiply (null , b ));
3738 }
3839
3940 @ Test
4041 void testNullMatrixB () {
4142 double [][] a = {{1 , 2 }, {3 , 4 }};
42- assertThrows (IllegalArgumentException .class ,
43- () -> MatrixMultiplication .multiply (a , null ));
43+ assertThrows (IllegalArgumentException .class , () -> MatrixMultiplication .multiply (a , null ));
4444 }
4545
4646 @ Test
4747 void testMultiplyNull () {
4848 double [][] matrixA = {{1.0 , 2.0 }, {3.0 , 4.0 }};
4949 double [][] matrixB = null ;
5050
51- Exception exception = assertThrows (IllegalArgumentException .class ,
52- () -> MatrixMultiplication .multiply (matrixA , matrixB ));
51+ Exception exception = assertThrows (IllegalArgumentException .class , () -> MatrixMultiplication .multiply (matrixA , matrixB ));
5352
5453 String expectedMessage = "Input matrices cannot be null" ;
5554 String actualMessage = exception .getMessage ();
@@ -61,16 +60,14 @@ void testMultiplyNull() {
6160 void testIncompatibleDimensions () {
6261 double [][] a = {{1.0 , 2.0 }};
6362 double [][] b = {{1.0 , 2.0 }};
64- assertThrows (IllegalArgumentException .class ,
65- () -> MatrixMultiplication .multiply (a , b ));
63+ assertThrows (IllegalArgumentException .class , () -> MatrixMultiplication .multiply (a , b ));
6664 }
6765
6866 @ Test
6967 void testEmptyMatrices () {
7068 double [][] a = new double [0 ][0 ];
7169 double [][] b = new double [0 ][0 ];
72- assertThrows (IllegalArgumentException .class ,
73- () -> MatrixMultiplication .multiply (a , b ));
70+ assertThrows (IllegalArgumentException .class , () -> MatrixMultiplication .multiply (a , b ));
7471 }
7572
7673 private void assertMatrixEquals (double [][] expected , double [][] actual ) {
0 commit comments