Skip to content

Commit

Permalink
Add tests for str::replacen
Browse files Browse the repository at this point in the history
  • Loading branch information
knight42 committed Sep 13, 2016
1 parent be2fa70 commit ebda770
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libcollectionstest/lib.rs
Expand Up @@ -21,6 +21,7 @@
#![feature(rand)]
#![feature(step_by)]
#![feature(str_escape)]
#![feature(str_replacen)]
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(unicode)]
Expand Down
14 changes: 14 additions & 0 deletions src/libcollectionstest/str.rs
Expand Up @@ -218,6 +218,20 @@ fn test_is_empty() {
assert!(!"a".is_empty());
}

#[test]
fn test_replacen() {
assert_eq!("".replacen('a', "b", 5), "");
assert_eq!("acaaa".replacen("a", "b", 3), "bcbba");
assert_eq!("aaaa".replacen("a", "b", 0), "aaaa");

let test = "test";
assert_eq!(" test test ".replacen(test, "toast", 3), " toast toast ");
assert_eq!(" test test ".replacen(test, "toast", 0), " test test ");
assert_eq!(" test test ".replacen(test, "", 5), " ");

assert_eq!("qwer123zxc789".replacen(char::is_numeric, "", 3), "qwerzxc789");
}

#[test]
fn test_replace() {
let a = "a";
Expand Down

0 comments on commit ebda770

Please sign in to comment.