@@ -19,8 +19,7 @@ void testBinarySearchFound() {
19
19
Integer [] array = {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 };
20
20
int key = 7 ;
21
21
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." );
24
23
}
25
24
26
25
/**
@@ -32,8 +31,7 @@ void testBinarySearchNotFound() {
32
31
Integer [] array = {1 , 2 , 3 , 4 , 5 };
33
32
int key = 6 ; // Element not present in the array
34
33
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." );
37
35
}
38
36
39
37
/**
@@ -45,8 +43,7 @@ void testBinarySearchFirstElement() {
45
43
Integer [] array = {1 , 2 , 3 , 4 , 5 };
46
44
int key = 1 ; // First element
47
45
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." );
50
47
}
51
48
52
49
/**
@@ -58,8 +55,7 @@ void testBinarySearchLastElement() {
58
55
Integer [] array = {1 , 2 , 3 , 4 , 5 };
59
56
int key = 5 ; // Last element
60
57
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." );
63
59
}
64
60
65
61
/**
@@ -71,8 +67,7 @@ void testBinarySearchSingleElementFound() {
71
67
Integer [] array = {1 };
72
68
int key = 1 ; // Only element present
73
69
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." );
76
71
}
77
72
78
73
/**
@@ -84,8 +79,7 @@ void testBinarySearchSingleElementNotFound() {
84
79
Integer [] array = {1 };
85
80
int key = 2 ; // Key not present
86
81
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." );
89
83
}
90
84
91
85
/**
@@ -97,8 +91,7 @@ void testBinarySearchEmptyArray() {
97
91
Integer [] array = {}; // Empty array
98
92
int key = 1 ; // Key not present
99
93
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." );
102
95
}
103
96
104
97
/**
@@ -110,7 +103,6 @@ void testBinarySearchLargeArray() {
110
103
Integer [] array = IntStream .range (0 , 10000 ).boxed ().toArray (Integer []::new ); // Array from 0 to 9999
111
104
int key = 9999 ; // Last element
112
105
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." );
115
107
}
116
108
}
0 commit comments