Skip to content

Commit

Permalink
Update test cases for equality testing
Browse files Browse the repository at this point in the history
  • Loading branch information
rubdos committed Jul 7, 2024
1 parent 0807ab4 commit 273a65b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/phone_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,14 @@ mod test {
};

let formatted = number.format().mode(mode).to_string();

if mode == Mode::National && country_hint.is_none() {
// If we are in national mode, we need to have a country hint
return Ok(());
}

let parsed = parser::parse(country_hint, &formatted).with_context(|| {
format!("parsing {number} after formatting in {mode:?} mode as {formatted}")
format!("parsing {number} with country hint {country_hint:?} after formatting in {mode:?} mode as {formatted}")
})?;

// impl Eq for PhoneNumber does not consider differently parsed phone numbers to be equal.
Expand All @@ -336,4 +342,12 @@ mod test {
) {
assert_eq!(r#type, number.number_type(&DATABASE));
}

#[test]
fn equality() {
let a = crate::parse(None, "+32474091150").unwrap();
let b = crate::parse(Some(BE), "0474091150").unwrap();

assert_eq!(a, b);
}
}

0 comments on commit 273a65b

Please sign in to comment.