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 a8358e6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,21 @@ 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 a8358e6

Please sign in to comment.