testing address
This commit is contained in:
parent
626874bedf
commit
fe6bd78f3c
2 changed files with 33 additions and 2 deletions
|
@ -72,6 +72,7 @@ pub fn address_list(input: &str) -> IResult<&str, Vec<AddressRef>> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::model::AddrSpec;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_mailbox_list() {
|
fn test_mailbox_list() {
|
||||||
|
@ -85,4 +86,34 @@ mod tests {
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_address_list() {
|
||||||
|
assert_eq!(
|
||||||
|
address_list(r#"A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;, Mary Smith <mary@x.test>"#),
|
||||||
|
Ok(("", vec![
|
||||||
|
AddressRef::Many(GroupRef {
|
||||||
|
name: "A Group".to_string(),
|
||||||
|
participants: vec![
|
||||||
|
MailboxRef {
|
||||||
|
name: Some("Ed Jones".into()),
|
||||||
|
addrspec: AddrSpec { local_part: "c".into(), domain: "a.test".into() },
|
||||||
|
},
|
||||||
|
MailboxRef {
|
||||||
|
name: None,
|
||||||
|
addrspec: AddrSpec { local_part: "joe".into(), domain: "where.test".into() },
|
||||||
|
},
|
||||||
|
MailboxRef {
|
||||||
|
name: Some("John".into()),
|
||||||
|
addrspec: AddrSpec { local_part: "jdoe".into(), domain: "one.test".into() },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
AddressRef::Single(MailboxRef {
|
||||||
|
name: Some("Mary Smith".into()),
|
||||||
|
addrspec: AddrSpec { local_part: "mary".into(), domain: "x.test".into() },
|
||||||
|
}),
|
||||||
|
]))
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ impl From<AddrSpec> for MailboxRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct GroupRef {
|
pub struct GroupRef {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub participants: Vec<MailboxRef>,
|
pub participants: Vec<MailboxRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum AddressRef {
|
pub enum AddressRef {
|
||||||
Single(MailboxRef),
|
Single(MailboxRef),
|
||||||
Many(GroupRef),
|
Many(GroupRef),
|
||||||
|
|
Loading…
Reference in a new issue