-
Notifications
You must be signed in to change notification settings - Fork 531
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
Fixes #310 Conform phone number unit test to NANP and updated track to 1.2.0 #359
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[package] | ||
name = "phone-number" | ||
version = "0.0.0" | ||
version = "1.2.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,90 +5,70 @@ fn to_some_string(s: &str) -> Option<String> { | |
} | ||
|
||
#[test] | ||
fn test_number_cleans() { | ||
assert_eq!(phone::number("(123) 456-7890"), to_some_string("1234567890")); | ||
fn test_cleans_the_number() { | ||
assert_eq!( | ||
phone::number("(223) 456-7890"), | ||
to_some_string("2234567890") | ||
); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please leave the |
||
fn test_number_cleans_with_dots() { | ||
assert_eq!(phone::number("123.456.7890"), to_some_string("1234567890")); | ||
fn test_cleans_numbers_with_dots() { | ||
assert_eq!(phone::number("223.456.7890"), to_some_string("2234567890")); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_valid_when_11_digits_and_first_is_1() { | ||
assert_eq!(phone::number("11234567890"), to_some_string("1234567890")); | ||
fn test_cleans_numbers_with_multiple_spaces() { | ||
assert_eq!( | ||
phone::number("223 456 7890 "), | ||
to_some_string("2234567890") | ||
); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_invalid_when_11_digits() { | ||
assert_eq!(phone::number("21234567890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_invalid_when_9_digits() { | ||
assert_eq!(phone::number("123456789"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_invalid_when_empty() { | ||
assert_eq!(phone::number(""), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_invalid_when_no_digits_present() { | ||
assert_eq!(phone::number(" (-) "), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_valid_with_leading_characters() { | ||
assert_eq!(phone::number("my number is 123 456 7890"), to_some_string("1234567890")); | ||
fn test_invalid_when_11_digits_does_not_start_with_a_1() { | ||
assert_eq!(phone::number("22234567890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_valid_with_trailing_characters() { | ||
assert_eq!(phone::number("123 456 7890 - bob"), to_some_string("1234567890")); | ||
fn test_valid_when_11_digits_and_starting_with_1() { | ||
assert_eq!(phone::number("12234567890"), to_some_string("2234567890")); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_area_code() { | ||
assert_eq!(phone::area_code("1234567890"), to_some_string("123")); | ||
fn test_valid_when_11_digits_and_starting_with_1_even_with_punctuation() { | ||
assert_eq!( | ||
phone::number("+1 (223) 456-7890"), | ||
to_some_string("2234567890") | ||
); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_area_code_with_full_us_phone_number() { | ||
assert_eq!(phone::area_code("18234567890"), to_some_string("823")); | ||
fn test_invalid_when_more_than_11_digits() { | ||
assert_eq!(phone::number("321234567890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_area_code_with_invalid() { | ||
assert_eq!(phone::area_code("1234161567890"), None); | ||
fn test_invalid_with_letters() { | ||
assert_eq!(phone::number("123-abc-7890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_pretty_print() { | ||
assert_eq!(phone::pretty_print("1234567890"), "(123) 456-7890"); | ||
fn test_invalid_with_punctuations() { | ||
assert_eq!(phone::number("123-@:!-7890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_pretty_print_with_full_us_phone_number() { | ||
assert_eq!(phone::pretty_print("11234567890"), "(123) 456-7890"); | ||
fn test_invalid_if_area_code_does_not_start_with_2_9() { | ||
assert_eq!(phone::number("(123) 456-7890"), None); | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_pretty_print_with_invalid() { | ||
assert_eq!(phone::pretty_print("1186234567890"), "invalid"); | ||
fn test_invalid_if_exchange_code_does_not_start_with_2_9() { | ||
assert_eq!(phone::number("(223) 056-7890"), None); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since
pretty_print
is no longer being tested, you can and should now remove this functionYou also can/should remove area_code