Skip to content

Commit

Permalink
tests: Add tests for replacen()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Berlin committed Nov 28, 2022
1 parent f7fd66e commit 07104e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/replace.rs
Expand Up @@ -228,3 +228,15 @@ replace!(
bytes!(&std::borrow::Cow::<'_, [u8]>::Owned(vec![b'Z'])),
"age: Z6"
);

#[test]
fn replacen_no_captures() {
let re = regex!(r"[0-9]");
assert_eq!(re.replacen(text!("age: 1234"), 2, t!("Z")), text!("age: ZZ34"));
}

#[test]
fn replacen_with_captures() {
let re = regex!(r"([0-9])");
assert_eq!(re.replacen(text!("age: 1234"), 2, t!("${1}Z")), text!("age: 1Z2Z34"));
}

0 comments on commit 07104e2

Please sign in to comment.