mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Add tests for Str.splitLast
There was only one test, which didn't cover the bug I fixed in Str.splitLast. I added the tests to make sure the bug will be caught in the future.
This commit is contained in:
parent
97f49bf940
commit
273907319d
1 changed files with 43 additions and 1 deletions
|
@ -1758,7 +1758,7 @@ fn str_split_first_not_found() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_split_last() {
|
||||
fn str_split_last_one_char() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
|
@ -1770,6 +1770,48 @@ fn str_split_last() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_split_last_multiple_chars() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.splitLast "foo//bar//baz" "//"
|
||||
"#
|
||||
),
|
||||
RocResult::ok((RocStr::from("baz"), RocStr::from("foo//bar"))),
|
||||
RocResult<(RocStr, RocStr), ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_split_last_entire_input() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.splitLast "foo" "foo"
|
||||
"#
|
||||
),
|
||||
RocResult::ok((RocStr::from(""), RocStr::from(""))),
|
||||
RocResult<(RocStr, RocStr), ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_split_last_not_found() {
|
||||
assert_evals_to!(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.splitFirst "foo" "bar"
|
||||
"#
|
||||
),
|
||||
RocResult::err(()),
|
||||
RocResult<(RocStr, RocStr), ()>
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(feature = "gen-llvm"))]
|
||||
fn str_walk_utf8_with_index() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue