@@ -8,67 +8,43 @@ public class DeterminantOfMatrixTest {
8
8
9
9
@ Test
10
10
public void testDeterminant2x2Matrix () {
11
- int [][] matrix = {
12
- {1 , 2 },
13
- {3 , 4 }
14
- };
11
+ int [][] matrix = {{1 , 2 }, {3 , 4 }};
15
12
int expected = -2 ;
16
13
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 2 ));
17
14
}
18
15
19
16
@ Test
20
17
public void testDeterminant3x3Matrix () {
21
- int [][] matrix = {
22
- {1 , 2 , 3 },
23
- {4 , 5 , 6 },
24
- {7 , 8 , 9 }
25
- };
18
+ int [][] matrix = {{1 , 2 , 3 }, {4 , 5 , 6 }, {7 , 8 , 9 }};
26
19
int expected = 0 ;
27
20
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 3 ));
28
21
}
29
22
30
23
@ Test
31
24
public void testDeterminant3x3MatrixNonZero () {
32
- int [][] matrix = {
33
- {1 , 2 , 3 },
34
- {0 , 1 , 4 },
35
- {5 , 6 , 0 }
36
- };
25
+ int [][] matrix = {{1 , 2 , 3 }, {0 , 1 , 4 }, {5 , 6 , 0 }};
37
26
int expected = 1 ;
38
27
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 3 ));
39
28
}
40
29
41
30
@ Test
42
31
public void testDeterminant1x1Matrix () {
43
- int [][] matrix = {
44
- {7 }
45
- };
32
+ int [][] matrix = {{7 }};
46
33
int expected = 7 ;
47
34
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 1 ));
48
35
}
49
36
50
37
@ Test
51
38
public void testDeterminant4x4Matrix () {
52
- int [][] matrix = {
53
- {1 , 0 , 0 , 1 },
54
- {0 , 1 , 0 , 0 },
55
- {0 , 0 , 1 , 0 },
56
- {1 , 0 , 0 , 1 }
57
- };
39
+ int [][] matrix = {{1 , 0 , 0 , 1 }, {0 , 1 , 0 , 0 }, {0 , 0 , 1 , 0 }, {1 , 0 , 0 , 1 }};
58
40
int expected = 0 ;
59
41
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 4 ));
60
42
}
61
43
62
44
@ Test
63
45
public void testDeterminant4x4MatrixZero () {
64
- int [][] matrix = {
65
- {1 , 2 , 3 , 4 },
66
- {5 , 6 , 7 , 8 },
67
- {9 , 10 , 11 , 12 },
68
- {13 , 14 , 15 , 16 }
69
- };
46
+ int [][] matrix = {{1 , 2 , 3 , 4 }, {5 , 6 , 7 , 8 }, {9 , 10 , 11 , 12 }, {13 , 14 , 15 , 16 }};
70
47
int expected = 0 ;
71
48
assertEquals (expected , DeterminantOfMatrix .determinant (matrix , 4 ));
72
49
}
73
50
}
74
-
0 commit comments