1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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
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
}