File tree Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Expand file tree Collapse file tree 3 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,9 @@ fake = "2.6.1"
35
35
reqwest = " 0.11.18"
36
36
once_cell = " 1"
37
37
claim = " 0.5"
38
+ quickcheck = " 1.0.3"
39
+ quickcheck_macros = " 1.0.0"
40
+ rand = " 0.8.5"
38
41
39
42
[profile .release ]
40
43
strip = true
Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ mod tests {
24
24
use claim:: { assert_err, assert_ok} ;
25
25
use fake:: faker:: internet:: en:: SafeEmail ;
26
26
use fake:: Fake ;
27
+ use quickcheck:: Gen ;
28
+ use rand:: { rngs:: StdRng , SeedableRng } ;
27
29
28
30
#[ test]
29
31
fn empty_string_is_rejected ( ) {
@@ -61,11 +63,20 @@ mod tests {
61
63
assert_err ! ( SubscriberEmail :: parse( email) ) ;
62
64
}
63
65
64
- #[ test]
65
- fn valid_emails_are_parsed_successfully ( ) {
66
- let email = SafeEmail ( ) . fake ( ) ;
67
- println ! ( "{}" , email) ;
68
- assert_ok ! ( SubscriberEmail :: parse( email) ) ;
66
+ #[ derive( Debug , Clone ) ]
67
+ struct ValidEmailFixture ( pub String ) ;
68
+
69
+ impl quickcheck:: Arbitrary for ValidEmailFixture {
70
+ fn arbitrary ( g : & mut Gen ) -> Self {
71
+ let mut rng = StdRng :: seed_from_u64 ( u64:: arbitrary ( g) ) ;
72
+ let email = SafeEmail ( ) . fake_with_rng ( & mut rng) ;
73
+ Self ( email)
74
+ }
69
75
}
70
76
77
+ #[ quickcheck_macros:: quickcheck]
78
+ fn valid_emails_are_parsed_successfully ( valid_email : ValidEmailFixture ) -> bool {
79
+ let ValidEmailFixture ( email) = valid_email;
80
+ SubscriberEmail :: parse ( email) . is_ok ( )
81
+ }
71
82
}
You can’t perform that action at this time.
0 commit comments