-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
79 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Seeds for failure cases proptest has generated in the past. It is | ||
# automatically read and these particular cases re-run before any | ||
# novel cases are generated. | ||
# | ||
# It is recommended to check this file in to source control so that | ||
# everyone who runs the test benefits from these saved cases. | ||
cc f4f1a19cf143c767508ab557480843e4f4093898768fbbea1034d19d4308257d # shrinks to tel_prefix = false, use_plus = true, s = "da", phone_context = Some("A0A0a") | ||
cc 4ea103e574793bd24b0267cc8a80962299ee50746d69332fbd0b85532fb707e2 # shrinks to tel_prefix = false, use_plus = false, s = "0", phone_context = Some("প") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use phonenumber::parse; | ||
use proptest::prelude::*; | ||
|
||
proptest! { | ||
#[test] | ||
fn rfc3966_crash_test( | ||
tel_prefix: bool, | ||
use_plus: bool, | ||
s: String, | ||
phone_context: Option<String>, | ||
) { | ||
let context = if let Some(phone_context) = &phone_context { format!(";phone-context={phone_context}") } else { "".to_string() }; | ||
let tel_prefix = if tel_prefix { "tel:" } else { "" }; | ||
let plus = if use_plus { "+" } else { "" }; | ||
let s = format!("{}{}{}{}", tel_prefix, plus, s, context); | ||
let _ = parse(None, &s); | ||
} | ||
|
||
#[test] | ||
fn doesnt_crash(s in "\\PC*") { | ||
let _ = parse(None, &s); | ||
} | ||
|
||
#[test] | ||
fn doesnt_crash_2(s in "\\+\\PC*") { | ||
let _ = parse(None, &s); | ||
} | ||
|
||
#[test] | ||
fn parse_belgian_phonenumbers(s in "\\+32[0-9]{8,9}") { | ||
let parsed = parse(None, &s).expect("valid Belgian number"); | ||
prop_assert_eq!(parsed.country().id(), phonenumber::country::BE.into()); | ||
} | ||
} |