aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/net/pub_domains.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/net/pub_domains.rs')
-rw-r--r--tests/unit/net/pub_domains.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit/net/pub_domains.rs b/tests/unit/net/pub_domains.rs
new file mode 100644
index 00000000000..60f2aa2b2e9
--- /dev/null
+++ b/tests/unit/net/pub_domains.rs
@@ -0,0 +1,38 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use net::pub_domains::is_pub_domain;
+
+#[test]
+fn test_is_pub_domain_plain() {
+ assert!(is_pub_domain("com"));
+ assert!(is_pub_domain(".org"));
+ assert!(is_pub_domain("za.org"));
+ assert!(is_pub_domain("xn--od0alg.hk"));
+ assert!(is_pub_domain("xn--krdsherad-m8a.no"));
+}
+
+#[test]
+fn test_is_pub_domain_wildcard() {
+ assert!(is_pub_domain("hello.bd"));
+ assert!(is_pub_domain("world.jm"));
+ assert!(is_pub_domain("toto.kobe.jp"));
+}
+
+#[test]
+fn test_is_pub_domain_exception() {
+ assert_eq!(is_pub_domain("www.ck"), false);
+ assert_eq!(is_pub_domain("city.kawasaki.jp"), false);
+ assert_eq!(is_pub_domain("city.nagoya.jp"), false);
+ assert_eq!(is_pub_domain("teledata.mz"), false);
+}
+
+#[test]
+fn test_is_pub_domain_not() {
+ assert_eq!(is_pub_domain(".servo.org"), false);
+ assert_eq!(is_pub_domain("www.mozilla.org"), false);
+ assert_eq!(is_pub_domain("publicsuffix.org"), false);
+ assert_eq!(is_pub_domain("hello.world.jm"), false);
+ assert_eq!(is_pub_domain("toto.toto.kobe.jp"), false);
+}