File tree 1 file changed +27
-1
lines changed
test/com/jwetherell/algorithms/data_structures/test
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1
1
package com .jwetherell .algorithms .data_structures .test ;
2
2
3
3
import static org .junit .Assert .assertTrue ;
4
-
4
+ import static org .junit .Assert .fail ;
5
+ import static org .junit .Assert .assertArrayEquals ;
5
6
import org .junit .Test ;
6
7
7
8
import com .jwetherell .algorithms .data_structures .Matrix ;
@@ -86,4 +87,29 @@ public void testMatrix() {
86
87
Matrix <Integer > matrix9 = matrix7 .multiply (matrix8 );
87
88
assertTrue ("Matrix multiplication error. matrix9=" +matrix9 +" result4" +result4 , matrix9 .equals (result4 ));
88
89
}
90
+
91
+ @ Test
92
+ public void testIdentityMethod1 () {
93
+ Matrix <Integer > matrix = new Matrix <Integer >(2 , 2 );
94
+ matrix .set (0 , 0 , 0 );
95
+ matrix .set (0 , 1 , 0 );
96
+ matrix .set (1 , 0 , 0 );
97
+ matrix .set (1 , 1 , 0 );
98
+
99
+ Matrix <Integer > expectedResult = new Matrix <Integer >(2 , 2 );
100
+ expectedResult .set (0 , 0 , 1 );
101
+ expectedResult .set (0 , 1 , 0 );
102
+ expectedResult .set (1 , 0 , 0 );
103
+ expectedResult .set (1 , 1 , 1 );
104
+
105
+ try {
106
+ matrix = matrix .identity ();
107
+ }
108
+ catch (Exception ex ){
109
+ fail ();
110
+ }
111
+
112
+ assertArrayEquals (expectedResult .getRow (0 ), matrix .getRow (0 ));
113
+ assertArrayEquals (expectedResult .getRow (1 ), matrix .getRow (1 ));
114
+ }
89
115
}
You can’t perform that action at this time.
0 commit comments