mirror of
https://github.com/TECHNOFAB11/tmux-copyrat.git
synced 2025-12-16 01:43:51 +01:00
feat: match email addresses
This commit is contained in:
parent
7ce0b517dc
commit
0f66b6fbd9
2 changed files with 24 additions and 1 deletions
22
src/model.rs
22
src/model.rs
|
|
@ -429,6 +429,28 @@ mod tests {
|
|||
assert_eq!(results.get(3).unwrap().pattern, "url");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_emails() {
|
||||
let buffer =
|
||||
"Lorem ipsum <first.last+social@example.com> john@server.department.company.com lorem";
|
||||
let named_pat = vec![];
|
||||
let custom = vec![];
|
||||
let alphabet = Alphabet("abcd".to_string());
|
||||
let results = Model::new(buffer, &alphabet, &named_pat, &custom, false).matches(false);
|
||||
|
||||
assert_eq!(results.len(), 2);
|
||||
assert_eq!(results.get(0).unwrap().pattern, "email");
|
||||
assert_eq!(
|
||||
results.get(0).unwrap().text,
|
||||
"first.last+social@example.com"
|
||||
);
|
||||
assert_eq!(results.get(1).unwrap().pattern, "email");
|
||||
assert_eq!(
|
||||
results.get(1).unwrap().text,
|
||||
"john@server.department.company.com"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_addresses() {
|
||||
let buffer = "Lorem 0xfd70b5695 0x5246ddf lorem\n Lorem 0x973113tlorem";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue