forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrixTest.java
More file actions
102 lines (76 loc) · 2.78 KB
/
MatrixTest.java
File metadata and controls
102 lines (76 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
public class MatrixTest {
@Test
public void extractRowFromOneNumberMatrixTest() {
String matrixAsString = "1";
int rowIndex = 1;
int[] expectedRow = {1};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedRow, matrix.getRow(rowIndex));
}
@Ignore("Remove to run test")
@Test
public void extractRowFromMatrixTest() {
String matrixAsString = "1 2\n3 4";
int rowIndex = 2;
int[] expectedRow = {3, 4};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedRow, matrix.getRow(rowIndex));
}
@Ignore("Remove to run test")
@Test
public void extractRowFromDiffWidthsMatrixTest() {
String matrixAsString = "1 2\n10 20";
int rowIndex = 2;
int[] expectedRow = {10, 20};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedRow, matrix.getRow(rowIndex));
}
@Ignore("Remove to run test")
@Test
public void extractRowFromNonSquareMatrixTest() {
String matrixAsString = "1 2 3\n4 5 6\n7 8 9\n8 7 6";
int rowIndex = 4;
int[] expectedRow = {8, 7, 6};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedRow, matrix.getRow(rowIndex));
}
@Ignore("Remove to run test")
@Test
public void extractColumnFromOneNumberMatrixTest() {
String matrixAsString = "1";
int columnIndex = 1;
int[] expectedColumn = {1};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedColumn, matrix.getColumn(columnIndex));
}
@Ignore("Remove to run test")
@Test
public void extractColumnMatrixTest() {
String matrixAsString = "1 2 3\n4 5 6\n7 8 9";
int columnIndex = 3;
int[] expectedColumn = {3, 6, 9};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedColumn, matrix.getColumn(columnIndex));
}
@Ignore("Remove to run test")
@Test
public void extractColumnFromNonSquareMatrixTest() {
String matrixAsString = "1 2 3 4\n5 6 7 8\n9 8 7 6";
int columnIndex = 4;
int[] expectedColumn = {4, 8, 6};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedColumn, matrix.getColumn(columnIndex));
}
@Ignore("Remove to run test")
@Test
public void extractColumnFromDiffWidthsMatrixTest() {
String matrixAsString = "89 1903 3\n18 3 1\n9 4 800";
int columnIndex = 2;
int[] expectedColumn = {1903, 3, 4};
Matrix matrix = new Matrix(matrixAsString);
assertArrayEquals(expectedColumn, matrix.getColumn(columnIndex));
}
}