Skip to content

Commit

Permalink
Add test case for parsing round trip
Browse files Browse the repository at this point in the history
This is a test for #46
  • Loading branch information
rubdos committed Apr 18, 2023
1 parent f1a7645 commit c9fb384
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/phone_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<'a> Deref for Country<'a> {
#[cfg(test)]
mod test {
use crate::country::{self, *};
use crate::{parser, PhoneNumber};
use crate::{parser, Mode, PhoneNumber};
use anyhow::Context;
use rstest::rstest;
use rstest_reuse::{self, *};
Expand Down Expand Up @@ -278,4 +278,20 @@ mod test {

Ok(())
}

#[apply(phone_numbers)]
#[ignore]
// Format-parse roundtrip
fn round_trip_parsing(
#[case] number: PhoneNumber,
#[case] _country: country::Id,
#[values(Mode::International, Mode::E164)] mode: Mode,
) -> anyhow::Result<()> {
let formatted = number.format().mode(mode).to_string();
parser::parse(None, &formatted).with_context(|| {
format!("parsing {number} after formatting in {mode:?} mode as {formatted}")
})?;

Ok(())
}
}

0 comments on commit c9fb384

Please sign in to comment.