mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
builtin: add string.split_any/1 (#12720)
This commit is contained in:
@ -229,6 +229,17 @@ fn test_split() {
|
||||
assert vals[1] == ''
|
||||
}
|
||||
|
||||
fn test_split_any() {
|
||||
assert 'ABC'.split_any('') == ['A', 'B', 'C']
|
||||
assert ''.split_any(' ') == []
|
||||
assert ' '.split_any(' ') == ['']
|
||||
assert ' '.split_any(' ') == ['', '']
|
||||
assert 'Ciao come stai? '.split_any(' ') == ['Ciao', 'come', 'stai?']
|
||||
assert 'Ciao+come*stai? '.split_any('+*') == ['Ciao', 'come', 'stai? ']
|
||||
assert 'Ciao+come*stai? '.split_any('+* ') == ['Ciao', 'come', 'stai?']
|
||||
assert 'first row\nsecond row'.split_any(' \n') == ['first', 'row', 'second', 'row']
|
||||
}
|
||||
|
||||
fn test_trim_space() {
|
||||
a := ' a '
|
||||
assert a.trim_space() == 'a'
|
||||
|
Reference in New Issue
Block a user