builtin: add string.trim_indent()` method (#17099)

This commit is contained in:
Makhnev Petr 2023-01-24 23:41:25 +04:00 committed by GitHub
parent 5aad0db0f7
commit 17d65db828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 244 additions and 0 deletions

View file

@ -1056,3 +1056,26 @@ fn test_string_is_ascii() {
fn test_string_with_zero_byte_escape() {
assert '\x00'.bytes() == [u8(0)]
}
fn test_is_blank() {
assert ''.is_blank()
assert ' '.is_blank()
assert ' \t'.is_blank()
assert ' \t
'.is_blank()
assert ' \t\r'.is_blank()
assert ' \t\r
'.is_blank()
}
fn test_indent_width() {
assert 'abc'.indent_width() == 0
assert ' abc'.indent_width() == 1
assert ' abc'.indent_width() == 2
assert '\tabc'.indent_width() == 1
assert '\t abc'.indent_width() == 2
assert '\t\tabc'.indent_width() == 2
assert '\t\t abc'.indent_width() == 3
}