@@ -281,6 +281,17 @@ defmodule StringTest do
281281 end
282282
283283 test :starts_with? do
284+ ## Normal cases ##
285+ assert String . starts_with? "hello" , "he"
286+ assert String . starts_with? "hello" , "hello"
287+ assert String . starts_with? "hello" , [ "hellö" , "hell" ]
288+ assert String . starts_with? "エリクシア" , "エリ"
289+ refute String . starts_with? "hello" , "lo"
290+ refute String . starts_with? "hello" , "hellö"
291+ refute String . starts_with? "hello" , [ "hellö" , "goodbye" ]
292+ refute String . starts_with? "エリクシア" , "仙丹"
293+
294+ ## Edge cases ##
284295 assert String . starts_with? "" , ""
285296 assert String . starts_with? "" , [ "" , "a" ]
286297 assert String . starts_with? "b" , [ "" , "a" ]
@@ -291,31 +302,16 @@ defmodule StringTest do
291302 refute String . starts_with? "" , "abc"
292303 refute String . starts_with? "" , [ " " ]
293304
294- assert String . starts_with? "hello" , "he"
295- assert String . starts_with? "hello" , "hello"
296- assert String . starts_with? "hello" , [ "hellö" , "hell" ]
297- assert String . starts_with? "エリクシア" , "エリ"
298- refute String . starts_with? "hello" , "lo"
299- refute String . starts_with? "hello" , "hellö"
300- refute String . starts_with? "hello" , [ "hellö" , "goodbye" ]
301- refute String . starts_with? "エリクシア" , "仙丹"
302-
305+ ## Sanity checks ##
306+ assert String . starts_with? "" , [ "" , "" ]
307+ assert String . starts_with? "abc" , [ "" , "" ]
303308 assert_raise ArgumentError , fn ->
304309 String . starts_with? "abc" , [ [ "a" ] , "a" ]
305310 end
306311 end
307312
308313 test :ends_with? do
309- assert String . ends_with? "" , ""
310- assert String . ends_with? "" , [ "" , "a" ]
311- refute String . ends_with? "" , [ "a" , "b" ]
312-
313- assert String . ends_with? "abc" , ""
314- assert String . ends_with? "abc" , [ "" , "x" ]
315-
316- refute String . ends_with? "" , "abc"
317- refute String . ends_with? "" , [ " " ]
318-
314+ ## Normal cases ##
319315 assert String . ends_with? "hello" , "lo"
320316 assert String . ends_with? "hello" , "hello"
321317 assert String . ends_with? "hello" , [ "hell" , "lo" , "xx" ]
@@ -326,6 +322,20 @@ defmodule StringTest do
326322 refute String . ends_with? "hello" , [ "hel" , "goodbye" ]
327323 refute String . ends_with? "エリクシア" , "仙丹"
328324
325+ ## Edge cases ##
326+ assert String . ends_with? "" , ""
327+ assert String . ends_with? "" , [ "" , "a" ]
328+ refute String . ends_with? "" , [ "a" , "b" ]
329+
330+ assert String . ends_with? "abc" , ""
331+ assert String . ends_with? "abc" , [ "" , "x" ]
332+
333+ refute String . ends_with? "" , "abc"
334+ refute String . ends_with? "" , [ " " ]
335+
336+ ## Sanity checks ##
337+ assert String . ends_with? "" , [ "" , "" ]
338+ assert String . ends_with? "abc" , [ "" , "" ]
329339 assert_raise ArgumentError , fn ->
330340 String . ends_with? "abc" , [ [ "c" ] , "c" ]
331341 end
0 commit comments