1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

builtin: consume matched string length in string.replace_each (#6349)

This commit is contained in:
Oghogho Odemwingie 2020-09-12 01:31:06 +01:00 committed by GitHub
parent b10d79c4d9
commit 332f3a924c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -292,7 +292,7 @@ pub fn (s string) replace_each(vals []string) string {
idx:idx
val_idx:rep_i
}
idx++
idx += rep.len
new_len += with.len - rep.len
}
}

View File

@ -285,6 +285,11 @@ fn test_replace_each() {
'[b]', '<b>',
'[/b]', '</b>',
]) == '<b>cool</b>'
t := 'aaaaaaaa'
y := t.replace_each([
'aa', 'b'
])
assert y == 'bbbb'
}
fn test_itoa() {

View File

@ -8,7 +8,7 @@ struct HttpbinResponseBody {
files map[string]string
form map[string]string
headers map[string]string
json ?map[string]string
json map[string]string
origin string
url string
}
@ -22,7 +22,7 @@ fn http_fetch_mock(_methods []string, _config FetchConfig) ?[]Response {
// Note: httpbin doesn't support head
for method in methods {
lmethod := method.to_lower()
config.method = method
config.method = method_from_str(method)
res := fetch(url + lmethod, config)?
// TODO
// body := json.decode(HttpbinResponseBody,res.text)?