-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more tests and run code coverage analysis #53
Conversation
Very nice! Thanks a lot. |
By trying this: diff --git a/src/phone_number.rs b/src/phone_number.rs
index fe028ef..8f466e0 100644
--- a/src/phone_number.rs
+++ b/src/phone_number.rs
@@ -294,10 +294,12 @@ mod test {
};
let formatted = number.format().mode(mode).to_string();
- parser::parse(country_hint, &formatted).with_context(|| {
+ let parsed = parser::parse(country_hint, &formatted).with_context(|| {
format!("parsing {number} after formatting in {mode:?} mode as {formatted}")
})?;
+ assert_eq!(number, parsed);
+
Ok(())
}
} I also discovered that the PhoneNumber Eq implementation is a bit wonky in my opinion:
I would expect those two numbers to satisfy Eq, but since they are parsed differently, they are not. Should we reconsider PartialEq/Eq implementations? |
Maybe we'd also want coverage analysis... |
Seems like coverage analysis works. https://app.codecov.io/github/whisperfish/rust-phonenumber/commit/15165d017b733bc38a27755eb3c0b042f83d447f Now I'll want to add some feedback in a comment, that's for |
Codecov Report
@@ Coverage Diff @@
## main #53 +/- ##
=======================================
Coverage ? 71.01%
=======================================
Files ? 19
Lines ? 1956
Branches ? 0
=======================================
Hits ? 1389
Misses ? 567
Partials ? 0 |
This effectively adds reproducers for the failing #46 and #47 cases.
I have refactored the parsing tests to be more verbose when they fail and easier to dissect. This adds rstest and anyhow as dev-dependencies.