Skip to content

Commit

Permalink
chore: added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaan26 committed Oct 3, 2024
1 parent 601ab48 commit bd6b97e
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions zung_mini/src/strsplit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,24 @@ mod tests {
assert_eq!(a.strsplit(",").into_vec(), vec!["a b c", " d e f"]);
}

#[test]
fn strsplit_from_and_into() {
let strsplit = "a b c d e f".strsplit(" ");
let vec1 = Vec::from(strsplit);
let vec2: Vec<&str> = strsplit.into();

assert_eq!(vec1, vec2)
}

#[test]
fn strsplit_empty_haystack() {
let haystack = "";
let needle = ",";

let vec = haystack.strsplit(needle).into_vec();
assert_eq!(vec, vec![""]);
}

#[test]
fn till_needle_finds_substring() {
let text = "hello world";
Expand Down Expand Up @@ -303,13 +321,4 @@ mod tests {
let result = text.till_needle("is");
assert_eq!(result, "th");
}

#[test]
fn test_from_and_into() {
let strsplit = "a b c d e f".strsplit(" ");
let vec1 = Vec::from(strsplit);
let vec2: Vec<&str> = strsplit.into();

assert_eq!(vec1, vec2)
}
}

0 comments on commit bd6b97e

Please sign in to comment.