File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 106106# @author https://github.com/SuperFola
107107(let setAt (fun (_str _index _x) (builtin__string:setAt _str _index _x)))
108108
109+ # @brief Check if a string is only ASCII
110+ # @param _str String where the lookup occurs
111+ # @author https://github.com/SuperFola
112+ (let ascii? (fun (_str) (= (len _str) (builtin__string:utf8len _str))))
113+
109114# @brief Check if a string contains a word
110115# @param _str String where the lookup occurs
111116# @param _word Word to look up for
Original file line number Diff line number Diff line change 1212 (test:eq (builtin__string:removeAt "abcd" -1) "abc")
1313 (test:eq (builtin__string:setAt "abcd" 1 "z") (string:setAt "abcd" 1 "z")) })
1414
15+ (test:case "ascii?" {
16+ (test:expect (string:ascii? ""))
17+ (test:expect (string:ascii? string:asciiLetters))
18+ (test:expect (string:ascii? string:whitespace))
19+ (test:expect (not (string:ascii? "abcdé")))
20+ (test:expect (not (string:ascii? "🏳️⚧️"))) })
21+
1522 (test:case "contains?" {
1623 (test:expect (string:contains? "hello, world" "h"))
1724 (test:expect (string:contains? "hello, world" "hello"))
You can’t perform that action at this time.
0 commit comments