mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
string: update string.repeat
behavior
Panic if a repeat count is negative. Return an empty string if a repeat count is zero.
This commit is contained in:
@ -603,11 +603,15 @@ fn test_limit() {
|
||||
}
|
||||
|
||||
fn test_repeat() {
|
||||
s := 'V! '
|
||||
assert s.repeat(5) == 'V! V! V! V! V! '
|
||||
assert s.repeat(1) == s
|
||||
assert s.repeat(0) == s
|
||||
assert s.repeat(-1) == s
|
||||
s1 := 'V! '
|
||||
assert s1.repeat(5) == 'V! V! V! V! V! '
|
||||
assert s1.repeat(1) == s1
|
||||
assert s1.repeat(0) == ''
|
||||
s2 := ''
|
||||
assert s2.repeat(5) == s2
|
||||
assert s2.repeat(1) == s2
|
||||
assert s2.repeat(0) == s2
|
||||
// TODO Add test for negative values
|
||||
}
|
||||
|
||||
fn test_raw() {
|
||||
|
Reference in New Issue
Block a user