@@ -219,4 +219,121 @@ void main() {
219219 expect (StringUtils .isIP ('0.0.0.256' ), false );
220220 expect (StringUtils .isIP ('26.0.0.256' ), false );
221221 });
222+
223+ group ('strip extension' , () {
224+ test ('strip' , () {
225+ // tested function's comment
226+ expect ('@£^£Some @£^ Thing@@£@^' .strip ('@£^' ), 'Some @£^ Thing' );
227+
228+ // edge cases that doesn't modify the string
229+ expect ('something' .strip ('@' ), 'something' );
230+ expect ('something' .strip ('@£^' ), 'something' );
231+ expect ('something' .strip ('' ), 'something' );
232+
233+ // remove a single character at either end from the source
234+ expect ('@something' .strip ('@' ), 'something' );
235+ expect ('@something@' .strip ('@' ), 'something' );
236+ expect ('something@' .strip ('@' ), 'something' );
237+
238+ // remove more than one character at either end from the source
239+ expect ('@@@something' .strip ('@' ), 'something' );
240+ expect ('@@something@@@' .strip ('@' ), 'something' );
241+ expect ('something@@@' .strip ('@' ), 'something' );
242+
243+ // search-string with multiple characters in it
244+ expect ('@£something' .strip ('@£' ), 'something' );
245+ expect ('@£something@£^' .strip ('@£^' ), 'something' );
246+ expect ('something@£^' .strip ('@£^' ), 'something' );
247+
248+ // source string with strip-chars in the middle
249+ expect ('@£some@£^thing' .strip ('@£' ), 'some@£^thing' );
250+ expect ('@£some@£^thing@£@' .strip ('@£' ), 'some@£^thing' );
251+ expect ('some@£^thing@£@' .strip ('@£' ), 'some@£^thing' );
252+
253+ // strip returns an empty string
254+ expect ('@@@@@£^^£@£' .strip ('@£^' ), '' );
255+ expect ('' .strip ('@£^' ), '' );
256+ expect ('' .strip ('' ), '' );
257+ expect ('2' .strip ('2' ), '' );
258+
259+ // results in a string with one character in it
260+ expect ('£@£@£@£@3@££££@^' .strip ('£@^' ), '3' );
261+ });
262+ test ('stripLeft' , () {
263+ // tested function's comment
264+ expect ('@£^£Some @£^ Thing@@£@^' .stripLeft ('@£^' ), 'Some @£^ Thing@@£@^' );
265+
266+ // edge cases that doesn't modify the string
267+ expect ('something' .stripLeft ('@' ), 'something' );
268+ expect ('something' .stripLeft ('@£^' ), 'something' );
269+ expect ('something' .stripLeft ('' ), 'something' );
270+
271+ // remove a single character at the beginning
272+ expect ('@something' .stripLeft ('@' ), 'something' );
273+ expect ('@something@' .stripLeft ('@' ), 'something@' );
274+ expect ('something@' .stripLeft ('@' ), 'something@' );
275+
276+ // remove more than one character from the beginning
277+ expect ('@@@something' .stripLeft ('@' ), 'something' );
278+ expect ('@@something@@@' .stripLeft ('@' ), 'something@@@' );
279+ expect ('something@@@' .stripLeft ('@' ), 'something@@@' );
280+
281+ // search-string with multiple characters in it
282+ expect ('@£something' .stripLeft ('@£' ), 'something' );
283+ expect ('@£something@£@' .stripLeft ('@£' ), 'something@£@' );
284+ expect ('something@£@' .stripLeft ('@£' ), 'something@£@' );
285+
286+ // source string with strip-chars in the middle
287+ expect ('@£some@£^thing' .stripLeft ('@£' ), 'some@£^thing' );
288+ expect ('@£some@£^thing@£@' .stripLeft ('@£' ), 'some@£^thing@£@' );
289+ expect ('some@£^thing@£@' .stripLeft ('@£' ), 'some@£^thing@£@' );
290+
291+ // strip returns an empty string
292+ expect ('@@@@@£^£@£' .stripLeft ('@£^' ), '' );
293+ expect ('' .stripLeft ('@£^' ), '' );
294+ expect ('' .stripLeft ('' ), '' );
295+ expect ('2' .stripLeft ('2' ), '' );
296+
297+ // results in a string with one character in it
298+ expect ('£@£@£@£@3' .stripLeft ('£@^' ), '3' );
299+ });
300+ test ('stripRight' , () {
301+ // tested function's comment
302+ expect ('@£^£Some @£^ Thing@@£@^' .stripRight ('@£^' ),'@£^£Some @£^ Thing' );
303+
304+ // edge cases that doesn't modify the string
305+ expect ('something' .stripRight ('@' ), 'something' );
306+ expect ('something' .stripRight ('@£^' ), 'something' );
307+ expect ('something' .stripRight ('' ), 'something' );
308+
309+ // remove a single character at the end
310+ expect ('@something' .stripRight ('@' ), '@something' );
311+ expect ('@something@' .stripRight ('@' ), '@something' );
312+ expect ('something@' .stripRight ('@' ), 'something' );
313+
314+ // remove more than one character from the end
315+ expect ('@@@something' .stripRight ('@' ), '@@@something' );
316+ expect ('@@something@@@' .stripRight ('@' ), '@@something' );
317+ expect ('something@@@' .stripRight ('@' ), 'something' );
318+
319+ // search-string with multiple characters in it
320+ expect ('@£something' .stripRight ('£@' ), '@£something' );
321+ expect ('@£something@£@' .stripRight ('@£' ), '@£something' );
322+ expect ('something@£@' .stripRight ('@£' ), 'something' );
323+
324+ // source string with strip-chars in the middle
325+ expect ('@£some@£^thing' .stripRight ('@£' ), '@£some@£^thing' );
326+ expect ('@£some@£^thing@£@' .stripRight ('@£' ), '@£some@£^thing' );
327+ expect ('some@£^thing@£@' .stripRight ('@£' ), 'some@£^thing' );
328+
329+ // strip returns an empty string
330+ expect ('@@@@@£^£@£' .stripRight ('@£^' ), '' );
331+ expect ('' .stripRight ('@£^' ), '' );
332+ expect ('' .stripRight ('' ), '' );
333+ expect ('2' .stripRight ('2' ), '' );
334+
335+ // results in a string with one character in it
336+ expect ('3@££££@^' .strip ('£@^' ), '3' );
337+ });
338+ });
222339}
0 commit comments