Skip to content

Commit f88ace4

Browse files
authored
Refactor matrix initialization for test cases
1 parent e2d6da3 commit f88ace4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.thealgorithms.matrix;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
import org.junit.jupiter.api.Test;
5+
6+
class StochasticMatrixTest {
7+
8+
@Test
9+
void testRowStochasticMatrix() {
10+
double[][] matrix = {{0.2, 0.5, 0.3},{0.1, 0.6, 0.3}};
11+
assertTrue(StochasticMatrix.isRowStochastic(matrix));
12+
assertFalse(StochasticMatrix.isColumnStochastic(matrix));
13+
}
14+
15+
@Test
16+
void testColumnStochasticMatrix() {
17+
double[][] matrix = {{0.4, 0.2},{0.6, 0.8}};
18+
assertTrue(StochasticMatrix.isColumnStochastic(matrix));
19+
}
20+
21+
@Test
22+
void testInvalidMatrix() {
23+
double[][] matrix = {{0.5, -0.5},{0.5, 1.5}};
24+
assertFalse(StochasticMatrix.isRowStochastic(matrix));
25+
}
26+
}

0 commit comments

Comments
 (0)