Skip to content

Commit 3180ab7

Browse files
committed
Fix
1 parent 68862a7 commit 3180ab7

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/test/java/com/thealgorithms/searches/BinarySearchTest.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ void testBinarySearchFound() {
1919
Integer[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
2020
int key = 7;
2121
int expectedIndex = 6; // Index of the key in the array
22-
assertEquals(expectedIndex, binarySearch.find(array, key),
23-
"The index of the found element should be 6.");
22+
assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the found element should be 6.");
2423
}
2524

2625
/**
@@ -32,8 +31,7 @@ void testBinarySearchNotFound() {
3231
Integer[] array = {1, 2, 3, 4, 5};
3332
int key = 6; // Element not present in the array
3433
int expectedIndex = -1; // Key not found
35-
assertEquals(expectedIndex, binarySearch.find(array, key),
36-
"The element should not be found in the array.");
34+
assertEquals(expectedIndex, binarySearch.find(array, key), "The element should not be found in the array.");
3735
}
3836

3937
/**
@@ -45,8 +43,7 @@ void testBinarySearchFirstElement() {
4543
Integer[] array = {1, 2, 3, 4, 5};
4644
int key = 1; // First element
4745
int expectedIndex = 0; // Index of the key in the array
48-
assertEquals(expectedIndex, binarySearch.find(array, key),
49-
"The index of the first element should be 0.");
46+
assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the first element should be 0.");
5047
}
5148

5249
/**
@@ -58,8 +55,7 @@ void testBinarySearchLastElement() {
5855
Integer[] array = {1, 2, 3, 4, 5};
5956
int key = 5; // Last element
6057
int expectedIndex = 4; // Index of the key in the array
61-
assertEquals(expectedIndex, binarySearch.find(array, key),
62-
"The index of the last element should be 4.");
58+
assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the last element should be 4.");
6359
}
6460

6561
/**
@@ -71,8 +67,7 @@ void testBinarySearchSingleElementFound() {
7167
Integer[] array = {1};
7268
int key = 1; // Only element present
7369
int expectedIndex = 0; // Index of the key in the array
74-
assertEquals(expectedIndex, binarySearch.find(array, key),
75-
"The index of the single element should be 0.");
70+
assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the single element should be 0.");
7671
}
7772

7873
/**
@@ -84,8 +79,7 @@ void testBinarySearchSingleElementNotFound() {
8479
Integer[] array = {1};
8580
int key = 2; // Key not present
8681
int expectedIndex = -1; // Key not found
87-
assertEquals(expectedIndex, binarySearch.find(array, key),
88-
"The element should not be found in the array.");
82+
assertEquals(expectedIndex, binarySearch.find(array, key), "The element should not be found in the array.");
8983
}
9084

9185
/**
@@ -97,8 +91,7 @@ void testBinarySearchEmptyArray() {
9791
Integer[] array = {}; // Empty array
9892
int key = 1; // Key not present
9993
int expectedIndex = -1; // Key not found
100-
assertEquals(expectedIndex, binarySearch.find(array, key),
101-
"The element should not be found in an empty array.");
94+
assertEquals(expectedIndex, binarySearch.find(array, key), "The element should not be found in an empty array.");
10295
}
10396

10497
/**
@@ -110,7 +103,6 @@ void testBinarySearchLargeArray() {
110103
Integer[] array = IntStream.range(0, 10000).boxed().toArray(Integer[]::new); // Array from 0 to 9999
111104
int key = 9999; // Last element
112105
int expectedIndex = 9999; // Index of the last element
113-
assertEquals(expectedIndex, binarySearch.find(array, key),
114-
"The index of the last element should be 9999.");
106+
assertEquals(expectedIndex, binarySearch.find(array, key), "The index of the last element should be 9999.");
115107
}
116108
}

0 commit comments

Comments
 (0)