@@ -16,8 +16,8 @@ BinarySearchTest = class(TTestCase)
1616 procedure finds_a_value_in_an_array_of_odd_length ;
1717 procedure finds_a_value_in_an_array_of_even_length ;
1818 procedure identifies_that_a_value_is_not_included_in_the_array ;
19- procedure a_value_smaller_than_the_array_s_smallest_value_is_not_found ;
20- procedure a_value_larger_than_the_array_s_largest_value_is_not_found ;
19+ procedure a_value_smaller_than_the_arrays_smallest_value_is_not_found ;
20+ procedure a_value_larger_than_the_arrays_largest_value_is_not_found ;
2121 procedure nothing_is_found_in_an_empty_array ;
2222 procedure nothing_is_found_when_the_left_and_right_bounds_cross ;
2323 end ;
@@ -30,8 +30,8 @@ procedure TapAssertExpectionMessage(
3030 ACase : TTestCase ;
3131 const AMessage : string ;
3232 const Expected : string ;
33- const AArray : TIntArray ;
34- const AValue : integer
33+ const AArray : TExtendedArray ;
34+ const AValue : Extended
3535);
3636var
3737 JsonMsg : string;
@@ -49,68 +49,101 @@ procedure TapAssertExpectionMessage(
4949
5050// b55c24a9-a98d-4379-a08c-2adcf8ebeee8
5151procedure BinarySearchTest.finds_a_value_in_an_array_with_one_element ;
52+ const
53+ haystack : TExtendedArray = (6 );
54+ needle : Extended = 6 ;
5255begin
53- TapAssertTrue(Self, ' finds a value in an array with one element' , 0 , BinarySearch.find([ 6 ], 6 ));
56+ TapAssertTrue(Self, ' finds a value in an array with one element' , 0 , BinarySearch.find(haystack, needle ));
5457end ;
5558
5659// 73469346-b0a0-4011-89bf-989e443d503d
5760procedure BinarySearchTest.finds_a_value_in_the_middle_of_an_array ;
61+ const
62+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
63+ needle : Extended = 6 ;
5864begin
59- TapAssertTrue(Self, ' finds a value in the middle of an array' , 3 , BinarySearch.find([ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 6 ));
65+ TapAssertTrue(Self, ' finds a value in the middle of an array' , 3 , BinarySearch.find(haystack, needle ));
6066end ;
6167
6268// 327bc482-ab85-424e-a724-fb4658e66ddb
6369procedure BinarySearchTest.finds_a_value_at_the_beginning_of_an_array ;
70+ const
71+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
72+ needle : Extended = 1 ;
6473begin
65- TapAssertTrue(Self, ' finds a value at the beginning of an array' , 0 , BinarySearch.find([ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 1 ));
74+ TapAssertTrue(Self, ' finds a value at the beginning of an array' , 0 , BinarySearch.find(haystack, needle ));
6675end ;
6776
6877// f9f94b16-fe5e-472c-85ea-c513804c7d59
6978procedure BinarySearchTest.finds_a_value_at_the_end_of_an_array ;
79+ const
80+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
81+ needle : Extended = 11 ;
7082begin
71- TapAssertTrue(Self, ' finds a value at the end of an array' , 6 , BinarySearch.find([ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 11 ));
83+ TapAssertTrue(Self, ' finds a value at the end of an array' , 6 , BinarySearch.find(haystack, needle ));
7284end ;
7385
7486// f0068905-26e3-4342-856d-ad153cadb338
7587procedure BinarySearchTest.finds_a_value_in_an_array_of_odd_length ;
88+ const
89+ haystack : TExtendedArray = (1 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 , 377 , 634 );
90+ needle : Extended = 144 ;
7691begin
77- TapAssertTrue(Self, ' finds a value in an array of odd length' , 9 , BinarySearch.find([ 1 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 , 377 , 634 ], 144 ));
92+ TapAssertTrue(Self, ' finds a value in an array of odd length' , 9 , BinarySearch.find(haystack, needle ));
7893end ;
7994
8095// fc316b12-c8b3-4f5e-9e89-532b3389de8c
8196procedure BinarySearchTest.finds_a_value_in_an_array_of_even_length ;
97+ const
98+ haystack : TExtendedArray = (1 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 , 377 );
99+ needle : Extended = 21 ;
82100begin
83- TapAssertTrue(Self, ' finds a value in an array of even length' , 5 , BinarySearch.find([ 1 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , 233 , 377 ], 21 ));
101+ TapAssertTrue(Self, ' finds a value in an array of even length' , 5 , BinarySearch.find(haystack, needle ));
84102end ;
85103
86104// da7db20a-354f-49f7-a6a1-650a54998aa6
87105procedure BinarySearchTest.identifies_that_a_value_is_not_included_in_the_array ;
106+ const
107+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
108+ needle : Extended = 7 ;
88109begin
89- TapAssertExpectionMessage(Self, ' identifies that a value is not included in the array' , ' value not in array' , [ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 7 );
110+ TapAssertExpectionMessage(Self, ' identifies that a value is not included in the array' , ' value not in array' , haystack, needle );
90111end ;
91112
92113// 95d869ff-3daf-4c79-b622-6e805c675f97
93- procedure BinarySearchTest.a_value_smaller_than_the_array_s_smallest_value_is_not_found ;
114+ procedure BinarySearchTest.a_value_smaller_than_the_arrays_smallest_value_is_not_found ;
115+ const
116+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
117+ needle : Extended = 0 ;
94118begin
95- TapAssertExpectionMessage(Self, ' a value smaller than the array '' s smallest value is not found' , ' value not in array' , [ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 0 );
119+ TapAssertExpectionMessage(Self, ' a value smaller than the arrays smallest value is not found' , ' value not in array' , haystack, needle );
96120end ;
97121
98122// 8b24ef45-6e51-4a94-9eac-c2bf38fdb0ba
99- procedure BinarySearchTest.a_value_larger_than_the_array_s_largest_value_is_not_found ;
123+ procedure BinarySearchTest.a_value_larger_than_the_arrays_largest_value_is_not_found ;
124+ const
125+ haystack : TExtendedArray = (1 , 3 , 4 , 6 , 8 , 9 , 11 );
126+ needle : Extended = 13 ;
100127begin
101- TapAssertExpectionMessage(Self, ' a value larger than the array '' s largest value is not found' , ' value not in array' , [ 1 , 3 , 4 , 6 , 8 , 9 , 11 ], 13 );
128+ TapAssertExpectionMessage(Self, ' a value larger than the arrays largest value is not found' , ' value not in array' , haystack, needle );
102129end ;
103130
104131// f439a0fa-cf42-4262-8ad1-64bf41ce566a
105132procedure BinarySearchTest.nothing_is_found_in_an_empty_array ;
133+ const
134+ haystack : TExtendedArray = ();
135+ needle : Extended = 1 ;
106136begin
107- TapAssertExpectionMessage(Self, ' nothing is found in an empty array' , ' value not in array' , [], 1 );
137+ TapAssertExpectionMessage(Self, ' nothing is found in an empty array' , ' value not in array' , haystack, needle );
108138end ;
109139
110140// 2c353967-b56d-40b8-acff-ce43115eed64
111141procedure BinarySearchTest.nothing_is_found_when_the_left_and_right_bounds_cross ;
142+ const
143+ haystack : TExtendedArray = (1 , 2 );
144+ needle : Extended = 0 ;
112145begin
113- TapAssertExpectionMessage(Self, ' nothing is found when the left and right bounds cross' , ' value not in array' , [ 1 , 2 ], 0 );
146+ TapAssertExpectionMessage(Self, ' nothing is found when the left and right bounds cross' , ' value not in array' , haystack, needle );
114147end ;
115148
116149initialization
0 commit comments