1
0
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:
penguindark
2021-12-04 19:13:40 +01:00
committed by GitHub
parent ace63594bf
commit 81a1490e31
2 changed files with 41 additions and 0 deletions

View File

@ -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'