utf8: reverse() to handle unicode strings (#10133)

This commit is contained in:
ScriptBoy2077 2021-05-19 17:24:08 +08:00 committed by GitHub
parent 2086e6f1c1
commit 4974fd09e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -68,3 +68,10 @@ fn test_raw_indexing() {
assert utf8.raw_index(a, 7) == 'g'
assert utf8.raw_index(a, 8) == '!'
}
fn test_reversed() {
a := 'V Lang!'
b := 'hello world'
assert utf8.reverse(a) == '!gnaL V'
assert utf8.reverse(b) == 'dlrow olleh'
}