-
Notifications
You must be signed in to change notification settings - Fork 17
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
2 changed files
with
86 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,6 +244,14 @@ fn list_behaviour() { | |
"#!$%&'*+-/=?^_`{}|[email protected]", | ||
"[email protected]", | ||
"user@[fd79:cdcb:38cc:9dd:f686:e06d:32f3:c123]", | ||
r#""Abc\@def"@example.com"#, | ||
r#""Fred Bloggs"@example.com"#, | ||
r#""Joe\\Blow"@example.com"#, | ||
r#""Abc@def"@example.com"#, | ||
r#"customer/[email protected]"#, | ||
"[email protected]", | ||
"!def!xyz%[email protected]", | ||
"[email protected]", | ||
]; | ||
for email in emails { | ||
println!("{} should be valid", email); | ||
|
@@ -252,6 +260,27 @@ fn list_behaviour() { | |
pass!() | ||
}); | ||
|
||
ctx.it("should reject invalid email addresses", || { | ||
let emails = vec![ | ||
"Abc.example.com", | ||
"A@b@[email protected]", | ||
r#"a"b(c)d,e:f;g<h>i[j\k][email protected]"#, | ||
r#""just"not"[email protected]"#, | ||
r#"this is"not\[email protected]"#, | ||
r#"this\ still\"not\\[email protected]"#, | ||
"1234567890123456789012345678901234567890123456789012345678901234+x@example.com", | ||
"[email protected]", | ||
"[email protected]", | ||
" [email protected]", | ||
"[email protected] ", | ||
]; | ||
for email in emails { | ||
println!("{} should not be valid", email); | ||
assert!(list.parse_email(email).is_err()); | ||
} | ||
pass!() | ||
}); | ||
|
||
ctx.it("should allow parsing emails as str", || { | ||
assert!(list.parse_str("[email protected]").unwrap().is_domain()); | ||
pass!() | ||
|
@@ -263,7 +292,18 @@ fn list_behaviour() { | |
}); | ||
|
||
ctx.it("should allow parsing IDN email addresses", || { | ||
assert!(list.parse_email("用户@例子.广告").is_ok()); | ||
let emails = vec![ | ||
r#"Pelé@example.com"#, | ||
r#"δοκιμή@παράδειγμα.δοκιμή"#, | ||
r#"我買@屋企.香港"#, | ||
r#"甲斐@黒川.日本"#, | ||
r#"чебурашка@ящик-с-апельсинами.рф"#, | ||
r#"संपर्क@डाटामेल.भारत"#, | ||
]; | ||
for email in emails { | ||
println!("{} should be valid", email); | ||
assert!(list.parse_email(email).is_ok()); | ||
} | ||
pass!() | ||
}); | ||
}); | ||
|