mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Add tests for str::replacen
This commit is contained in:
parent
be2fa70c16
commit
ebda77072a
@ -21,6 +21,7 @@
|
||||
#![feature(rand)]
|
||||
#![feature(step_by)]
|
||||
#![feature(str_escape)]
|
||||
#![feature(str_replacen)]
|
||||
#![feature(test)]
|
||||
#![feature(unboxed_closures)]
|
||||
#![feature(unicode)]
|
||||
|
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user