mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 04:08:19 +00:00
Add some expects to Str
This commit is contained in:
parent
d415c72fdc
commit
807f73fecf
1 changed files with 9 additions and 0 deletions
|
@ -330,6 +330,15 @@ splitLast = \haystack, needle ->
|
|||
None ->
|
||||
Err NotFound
|
||||
|
||||
# splitLast when needle isn't in haystack
|
||||
expect Str.splitLast "foo" "z" == Err NotFound
|
||||
|
||||
# splitLast when haystack ends with needle repeated
|
||||
expect Str.splitLast "foo" "o" == Ok { before: "fo", after: "" }
|
||||
|
||||
# splitLast with multi-byte needle
|
||||
expect Str.splitLast "hullabaloo" "ab" == Ok { before: "hull", after: "aloo" }
|
||||
|
||||
lastMatch : Str, Str -> [Some Nat, None]
|
||||
lastMatch = \haystack, needle ->
|
||||
haystackLength = Str.countUtf8Bytes haystack
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue