mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
builtin: add string.camel_to_snake/0 and string.snake_to_camel/0 methods (#21679)
This commit is contained in:
parent
3ad77b2551
commit
df1e4f1246
2 changed files with 108 additions and 0 deletions
|
@ -1521,3 +1521,17 @@ fn test_contains_byte() {
|
|||
assert 'abc abca'.contains_u8(` `)
|
||||
assert !'abc abca'.contains_u8(`A`)
|
||||
}
|
||||
|
||||
fn test_camel_to_snake() {
|
||||
assert 'Abcd'.camel_to_snake() == 'abcd'
|
||||
assert 'aaBB'.camel_to_snake() == 'aa_bb'
|
||||
assert 'BBaa'.camel_to_snake() == 'b_baa'
|
||||
assert 'aa_BB'.camel_to_snake() == 'aa_bb'
|
||||
}
|
||||
|
||||
fn test_snake_to_camel() {
|
||||
assert 'abcd'.snake_to_camel() == 'Abcd'
|
||||
assert 'ab_cd'.snake_to_camel() == 'AbCd'
|
||||
assert '_abcd'.snake_to_camel() == 'Abcd'
|
||||
assert '_abcd_'.snake_to_camel() == 'Abcd'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue