Skip to content

Commit 3367582

Browse files
committed
test: increase SearchSortedMatrix coverage
1 parent c233567 commit 3367582

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/test/java/com/thealgorithms/matrix/SearchSortedMatrixTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ void emptyFirstRowReturnsFalse() {
2525
assertFalse(SearchSortedMatrix.search(new int[][] {{}}, 42));
2626
}
2727

28+
@Test
29+
void nullFirstRowReturnsFalse() {
30+
assertFalse(SearchSortedMatrix.search(new int[][] {null}, 42));
31+
}
32+
2833
@Test
2934
void findsExistingTargetInTypicalMatrix() {
3035
final int[][] matrix = {
@@ -40,6 +45,16 @@ void findsExistingTargetInTypicalMatrix() {
4045
assertTrue(SearchSortedMatrix.search(matrix, 1));
4146
}
4247

48+
@Test
49+
void intSearchCoversAllComparisonBranches() {
50+
final int[][] matrix = {
51+
{1, 4},
52+
{2, 5},
53+
};
54+
55+
assertTrue(SearchSortedMatrix.search(matrix, 2));
56+
}
57+
4358
@Test
4459
void genericSearchFindsExistingTarget() {
4560
final Integer[][] matrix = {
@@ -54,6 +69,16 @@ void genericSearchFindsExistingTarget() {
5469
assertFalse(SearchSortedMatrix.search(matrix, 20, Comparator.naturalOrder()));
5570
}
5671

72+
@Test
73+
void genericSearchCoversAllComparisonBranches() {
74+
final Integer[][] matrix = {
75+
{1, 4},
76+
{2, 5},
77+
};
78+
79+
assertTrue(SearchSortedMatrix.search(matrix, 2, Comparator.naturalOrder()));
80+
}
81+
5782
@Test
5883
void genericNullMatrixReturnsFalse() {
5984
assertFalse(SearchSortedMatrix.search((Integer[][]) null, 42, Comparator.naturalOrder()));

0 commit comments

Comments
 (0)