@@ -281,6 +281,17 @@ defmodule StringTest do
281
281
end
282
282
283
283
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 ##
284
295
assert String . starts_with? "" , ""
285
296
assert String . starts_with? "" , [ "" , "a" ]
286
297
assert String . starts_with? "b" , [ "" , "a" ]
@@ -291,31 +302,16 @@ defmodule StringTest do
291
302
refute String . starts_with? "" , "abc"
292
303
refute String . starts_with? "" , [ " " ]
293
304
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" , [ "" , "" ]
303
308
assert_raise ArgumentError , fn ->
304
309
String . starts_with? "abc" , [ [ "a" ] , "a" ]
305
310
end
306
311
end
307
312
308
313
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 ##
319
315
assert String . ends_with? "hello" , "lo"
320
316
assert String . ends_with? "hello" , "hello"
321
317
assert String . ends_with? "hello" , [ "hell" , "lo" , "xx" ]
@@ -326,6 +322,20 @@ defmodule StringTest do
326
322
refute String . ends_with? "hello" , [ "hel" , "goodbye" ]
327
323
refute String . ends_with? "エリクシア" , "仙丹"
328
324
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" , [ "" , "" ]
329
339
assert_raise ArgumentError , fn ->
330
340
String . ends_with? "abc" , [ [ "c" ] , "c" ]
331
341
end
0 commit comments