From d332557d691babdcfc5b27f61eb1aeeb90f13f1e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 30 Nov 2015 22:56:13 +0530 Subject: [PATCH] Add path_match tests --- tests/unit/net/cookie.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/unit/net/cookie.rs b/tests/unit/net/cookie.rs index c2e1486aa3c..18058cc336f 100644 --- a/tests/unit/net/cookie.rs +++ b/tests/unit/net/cookie.rs @@ -25,6 +25,23 @@ fn test_domain_match() { assert!(!Cookie::domain_match("235.132.2.3", ".2.3")); } +#[test] +fn test_path_match() { + assert!(Cookie::path_match("/", "/")); + assert!(Cookie::path_match("/index.html", "/")); + assert!(Cookie::path_match("/w/index.html", "/")); + assert!(Cookie::path_match("/w/index.html", "/w/index.html")); + assert!(Cookie::path_match("/w/index.html", "/w/")); + assert!(Cookie::path_match("/w/index.html", "/w")); + + assert!(!Cookie::path_match("/", "/w/")); + assert!(!Cookie::path_match("/a", "/w/")); + assert!(!Cookie::path_match("/", "/w")); + assert!(!Cookie::path_match("/w/index.html", "/w/index")); + assert!(!Cookie::path_match("/windex.html", "/w/")); + assert!(!Cookie::path_match("/windex.html", "/w")); +} + #[test] fn test_default_path() { assert!(&*Cookie::default_path("/foo/bar/baz/") == "/foo/bar/baz");