mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: add string.replace_char and string.normalize_tabs (#15239)
This commit is contained in:
@@ -380,6 +380,18 @@ fn test_replace_each() {
|
||||
assert s2.replace_each(['hello_world', 'aaa', 'hello', 'bbb']) == 'aaa bbb'
|
||||
}
|
||||
|
||||
fn test_replace_char() {
|
||||
assert 'azert'.replace_char(`z`, `s`, 2) == 'assert'
|
||||
assert '\rHello!\r'.replace_char(`\r`, `\n`, 1) == '\nHello!\n'
|
||||
assert 'Hello!'.replace_char(`l`, `e`, 4) == 'Heeeeeeeeeo!'
|
||||
assert '1141'.replace_char(`1`, `8`, 2) == '8888488'
|
||||
}
|
||||
|
||||
fn test_normalize_tabs() {
|
||||
assert '\t\tHello!'.normalize_tabs(4) == ' Hello!'
|
||||
assert '\t\tHello!\t; greeting'.normalize_tabs(1) == ' Hello! ; greeting'
|
||||
}
|
||||
|
||||
fn test_itoa() {
|
||||
num := 777
|
||||
assert num.str() == '777'
|
||||
|
Reference in New Issue
Block a user