Skip to content

Commit

Permalink
Added PropTest Crate And Added Prop Tests to SubscriberName
Browse files Browse the repository at this point in the history
Signed-off-by: Anthony M. Bonafide <anthony.bonafide@shipt.com>
  • Loading branch information
AnthonyMBonafide committed Jul 6, 2024
1 parent a001c0a commit 01675a7
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
78 changes: 78 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ fake = "2.9.2"
rand = "0.8.5"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
proptest = "1.5.0"
8 changes: 8 additions & 0 deletions proptest-regressions/domain/subscriber_name.txt
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 4b4aee0fb8ff56c41c64cc88c4b18dd032f817b8cf33f0baf0f3f06ab5ad8d0b # shrinks to value = "("
cc 59ae9b6babd587b3cda088c8e75789f506ace862b47a2c5408b314c60517e1b5 # shrinks to value = "0A#\0\00aaa##¡*0\0¡¡\0*]a¡\0aa¡¡~~0¡\0*|~a\0#~¡a0#a¡~a~*\0~¡A0A~a¡]\0#=0¡A¡¡|\00¡*a=*a\0~#A=0]¡0 a*\0##\0*~¡¡||#¡¡~¡a0]#\0*A=|0¡##=¡a\0\0#=AA#A=# =\00**¡=*a¡\0¡~0¡A*a\0|#Aa=#\0]¡\0¡#?*\0\0A\0A=#A*¡¡000¡AA¡\0\0¡a=a|aa##A\0#a¡*=A=~A?0a]\0\0##aa=\0\0#¡?*]#*|0aaa##¡a0A#A|A¡#=#¡a~A\0AA#\0\0¡a0¡"
13 changes: 13 additions & 0 deletions src/domain/subscriber_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ impl SubscriberName {
#[cfg(test)]
mod test {
use super::{SubscriberName, INVALID_CHARACTERS};
use proptest::prelude::*;

proptest! {
#[test]
fn parse_valid_names(value in r#"[^/()"<>\\{}]{1,256}"#) {
prop_assert!(SubscriberName::parse(value).is_ok());
}

#[test]
fn reject_long_names(value in r#"[^/()"<>\\{}]{257,}"#) {
prop_assert!(SubscriberName::parse(value).is_err());
}
}

#[test]
fn a_256_grapheme_long_name_is_valid() {
Expand Down

0 comments on commit 01675a7

Please sign in to comment.