Add tests for str::replacen

This commit is contained in:
knight42 2016-09-08 18:55:04 +08:00
parent be2fa70c16
commit ebda77072a
2 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#![feature(rand)]
#![feature(step_by)]
#![feature(str_escape)]
#![feature(str_replacen)]
#![feature(test)]
#![feature(unboxed_closures)]
#![feature(unicode)]

View File

@ -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";