fix memory leak in string trimming

This commit is contained in:
Folkert 2023-01-16 20:58:19 +01:00
parent 2105a14e21
commit 165d4b3450
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
2 changed files with 48 additions and 10 deletions

View file

@ -250,3 +250,31 @@ fn list_concat_empty_list_zero_sized_type() {
"#
));
}
#[test]
fn str_trim_right_capacity() {
valgrind_test(indoc!(
r#"
(
str = "a" |> Str.reserve 30
out = str |> Str.trimRight
if out == "" then "A" else "B"
)
"#
));
}
#[test]
fn str_trim_left_capacity() {
valgrind_test(indoc!(
r#"
(
str = " a" |> Str.reserve 30
out = str |> Str.trimLeft
if out == "" then "A" else "B"
)
"#
));
}