@@ -130,6 +130,46 @@ begin
130130 counting_assert(count(reverse_string, " a" , 12 ,4 ) = 0 , " Should not find anything outside of the string" );
131131 counting_assert(count(" aba" , " a" , 3 ,1 ) = 0 , " Should not find anything within a negative range" );
132132 counting_assert(count(" aba" , " abab" ) = 0 , " Should not find anything when substring is longer than the string" );
133+ elsif run(" Test find" ) then
134+ counting_assert(find(" " , " " ) = 1 , " Empty string should be found at the start" );
135+ counting_assert(find(" foo bar" , " " ) = 1 , " Empty string should be found at the start" );
136+ counting_assert(find(" foo bar" , " foo" ) = 1 , " Should find string at the start" );
137+ counting_assert(find(" foo bar" , " bar" ) = 5 , " Should find string at the end" );
138+ counting_assert(find(" foo bar" , " o b" ) = 3 , " Should find string in the middle" );
139+ counting_assert(find(" foo bar" , " foo bar" ) = 1 , " Should find full string" );
140+ counting_assert(find(" foo bar" , ' f' ) = 1 , " Should find character at the start" );
141+ counting_assert(find(" foo bar" , ' r' ) = 7 , " Should find character at the end" );
142+ counting_assert(find(" foo bar" , ' ' ) = 4 , " Should find character in the middle" );
143+ counting_assert(find(" foo bar" , " bars" ) = 0 , " Should return 0 when string not found" );
144+ counting_assert(find(" foo bar" , " foo bars" ) = 0 , " Should return 0 when string not found" );
145+ counting_assert(find(" foo bar" , ' q' ) = 0 , " Should return 0 when character not found" );
146+ counting_assert(find(offset_string, " " ) = 10 , " Empty string should be found at the start on offset string" );
147+ counting_assert(find(offset_string, " foo" ) = 10 , " Should find string at the start on offset string" );
148+ counting_assert(find(offset_string, " bar" ) = 14 , " Should find string at the end on offset string" );
149+ counting_assert(find(offset_string, " o b" ) = 12 , " Should find string in the middle on offset string" );
150+ counting_assert(find(reverse_string, " " ) = 16 , " Empty string should be found at the start on reversed string" );
151+ counting_assert(find(reverse_string, " foo" ) = 16 , " Should find string at the start on reversed string" );
152+ counting_assert(find(reverse_string, " bar" ) = 12 , " Should find string at the end on reversed string" );
153+ counting_assert(find(reverse_string, " o b" ) = 14 , " Should find string in the middle on reversed string" );
154+ counting_assert(find(" foo bar" , " oo" , 2 , 6 ) = 2 , " Should find string at the start of slice" );
155+ counting_assert(find(" foo bar" , " ba" , 2 , 6 ) = 5 , " Should find string at the end of slice" );
156+ counting_assert(find(" foo bar" , " o b" , 2 , 6 ) = 3 , " Should find string in the middle of slice" );
157+ counting_assert(find(" foo bar" , " " , 2 , 6 ) = 2 , " Empty string should be found at the start of slice" );
158+ counting_assert(find(" foo bar" , ' f' , 2 , 6 ) = 0 , " Should not find anything before slice" );
159+ counting_assert(find(" foo bar" , " ar" , 2 , 6 ) = 0 , " Should not find anything after slice" );
160+ counting_assert(find(offset_string, ' f' , 11 , 15 ) = 0 , " Should not find anything before slice in offset string" );
161+ counting_assert(find(offset_string, " ar" , 11 , 15 ) = 0 , " Should not find anything after slice in offset string" );
162+ counting_assert(find(reverse_string, ' f' , 15 , 11 ) = 0 , " Should not find anything before slice in reversed string" );
163+ counting_assert(find(reverse_string, " ar" , 15 , 11 ) = 0 , " Should not find anything after slice in reversed string" );
164+ counting_assert(find(" foo bar" , " o b" , 1 , 100 ) = 3 , " Should find in ranges wider than input'range" );
165+ counting_assert(find(" foo bar" , " zen" , 1 , 100 ) = 0 , " Should not find in ranges wider than input'range" );
166+ counting_assert(find(offset_string, " o b" , 1 , 100 ) = 12 , " Should find in ranges wider than input'range" );
167+ counting_assert(find(offset_string, " zen" , 1 , 100 ) = 0 , " Should not find in ranges wider than input'range" );
168+ counting_assert(find(reverse_string, " o b" , 100 , 1 ) = 14 , " Should find in ranges wider than input'range" );
169+ counting_assert(find(reverse_string, " zen" , 100 , 1 ) = 0 , " Should not find in ranges wider than input'range" );
170+ counting_assert(find(" foo bar" , " o b" , 3 , 2 ) = 0 , " Should not find string in negative range" );
171+ counting_assert(find(" foo bar" , " o b" , 30 , 0 ) = 0 , " Should not find string in negative range" );
172+ counting_assert(find(reverse_string, " o b" , 1 , 100 ) = 0 , " Should not find string in negative range" );
133173
134174 elsif run(" Test image" ) then
135175 counting_assert(image (" " ) = " " , " Should return empty string on empty input vector." );
0 commit comments