@@ -12,67 +12,43 @@ class SaddlebackSearchTest {
12
12
*/
13
13
@ Test
14
14
void testFindElementExists () {
15
- int [][] arr = {
16
- {-10 , -5 , -3 , 4 , 9 },
17
- {-6 , -2 , 0 , 5 , 10 },
18
- {-4 , -1 , 1 , 6 , 12 },
19
- {2 , 3 , 7 , 8 , 13 },
20
- {100 , 120 , 130 , 140 , 150 }
21
- };
15
+ int [][] arr = {{-10 , -5 , -3 , 4 , 9 }, {-6 , -2 , 0 , 5 , 10 }, {-4 , -1 , 1 , 6 , 12 }, {2 , 3 , 7 , 8 , 13 }, {100 , 120 , 130 , 140 , 150 }};
22
16
23
17
int [] result = SaddlebackSearch .find (arr , arr .length - 1 , 0 , 4 );
24
- assertArrayEquals (new int []{0 , 3 }, result , "Element 4 should be found at (0, 3)" );
18
+ assertArrayEquals (new int [] {0 , 3 }, result , "Element 4 should be found at (0, 3)" );
25
19
}
26
20
27
21
/**
28
22
* Test searching for an element that does not exist in the array.
29
23
*/
30
24
@ Test
31
25
void testFindElementNotExists () {
32
- int [][] arr = {
33
- {-10 , -5 , -3 , 4 , 9 },
34
- {-6 , -2 , 0 , 5 , 10 },
35
- {-4 , -1 , 1 , 6 , 12 },
36
- {2 , 3 , 7 , 8 , 13 },
37
- {100 , 120 , 130 , 140 , 150 }
38
- };
26
+ int [][] arr = {{-10 , -5 , -3 , 4 , 9 }, {-6 , -2 , 0 , 5 , 10 }, {-4 , -1 , 1 , 6 , 12 }, {2 , 3 , 7 , 8 , 13 }, {100 , 120 , 130 , 140 , 150 }};
39
27
40
28
int [] result = SaddlebackSearch .find (arr , arr .length - 1 , 0 , 1000 );
41
- assertArrayEquals (new int []{-1 , -1 }, result , "Element 1000 should not be found" );
29
+ assertArrayEquals (new int [] {-1 , -1 }, result , "Element 1000 should not be found" );
42
30
}
43
31
44
32
/**
45
33
* Test searching for the smallest element in the array.
46
34
*/
47
35
@ Test
48
36
void testFindSmallestElement () {
49
- int [][] arr = {
50
- {-10 , -5 , -3 , 4 , 9 },
51
- {-6 , -2 , 0 , 5 , 10 },
52
- {-4 , -1 , 1 , 6 , 12 },
53
- {2 , 3 , 7 , 8 , 13 },
54
- {100 , 120 , 130 , 140 , 150 }
55
- };
37
+ int [][] arr = {{-10 , -5 , -3 , 4 , 9 }, {-6 , -2 , 0 , 5 , 10 }, {-4 , -1 , 1 , 6 , 12 }, {2 , 3 , 7 , 8 , 13 }, {100 , 120 , 130 , 140 , 150 }};
56
38
57
39
int [] result = SaddlebackSearch .find (arr , arr .length - 1 , 0 , -10 );
58
- assertArrayEquals (new int []{0 , 0 }, result , "Element -10 should be found at (0, 0)" );
40
+ assertArrayEquals (new int [] {0 , 0 }, result , "Element -10 should be found at (0, 0)" );
59
41
}
60
42
61
43
/**
62
44
* Test searching for the largest element in the array.
63
45
*/
64
46
@ Test
65
47
void testFindLargestElement () {
66
- int [][] arr = {
67
- {-10 , -5 , -3 , 4 , 9 },
68
- {-6 , -2 , 0 , 5 , 10 },
69
- {-4 , -1 , 1 , 6 , 12 },
70
- {2 , 3 , 7 , 8 , 13 },
71
- {100 , 120 , 130 , 140 , 150 }
72
- };
48
+ int [][] arr = {{-10 , -5 , -3 , 4 , 9 }, {-6 , -2 , 0 , 5 , 10 }, {-4 , -1 , 1 , 6 , 12 }, {2 , 3 , 7 , 8 , 13 }, {100 , 120 , 130 , 140 , 150 }};
73
49
74
50
int [] result = SaddlebackSearch .find (arr , arr .length - 1 , 0 , 150 );
75
- assertArrayEquals (new int []{4 , 4 }, result , "Element 150 should be found at (4, 4)" );
51
+ assertArrayEquals (new int [] {4 , 4 }, result , "Element 150 should be found at (4, 4)" );
76
52
}
77
53
78
54
/**
@@ -93,7 +69,7 @@ void testFindSingleElementExists() {
93
69
int [][] arr = {{5 }};
94
70
95
71
int [] result = SaddlebackSearch .find (arr , 0 , 0 , 5 );
96
- assertArrayEquals (new int []{0 , 0 }, result , "Element 5 should be found at (0, 0)" );
72
+ assertArrayEquals (new int [] {0 , 0 }, result , "Element 5 should be found at (0, 0)" );
97
73
}
98
74
99
75
/**
@@ -104,6 +80,6 @@ void testFindSingleElementNotExists() {
104
80
int [][] arr = {{5 }};
105
81
106
82
int [] result = SaddlebackSearch .find (arr , 0 , 0 , 10 );
107
- assertArrayEquals (new int []{-1 , -1 }, result , "Element 10 should not be found in single element array" );
83
+ assertArrayEquals (new int [] {-1 , -1 }, result , "Element 10 should not be found in single element array" );
108
84
}
109
85
}
0 commit comments