|
|
@@ -79,63 +79,3 @@ impl<'a> fmt::Display for UrlNoFragmentFormatter<'a> {
|
|
|
Ok(())
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-/// Formatting Tests
|
|
|
-#[cfg(test)]
|
|
|
-mod tests {
|
|
|
- use super::super::Url;
|
|
|
- use super::{PathFormatter, UserInfoFormatter};
|
|
|
-
|
|
|
- #[test]
|
|
|
- fn path_formatting() {
|
|
|
- let data = [
|
|
|
- (vec![], "/"),
|
|
|
- (vec![""], "/"),
|
|
|
- (vec!["test", "path"], "/test/path"),
|
|
|
- (vec!["test", "path", ""], "/test/path/")
|
|
|
- ];
|
|
|
- for &(ref path, result) in &data {
|
|
|
- assert_eq!(PathFormatter {
|
|
|
- path: path
|
|
|
- }.to_string(), result.to_string());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #[test]
|
|
|
- fn userinfo_formatting() {
|
|
|
- // Test data as (username, password, result) tuples.
|
|
|
- let data = [
|
|
|
- ("", None, ""),
|
|
|
- ("", Some(""), ":@"),
|
|
|
- ("", Some("password"), ":password@"),
|
|
|
- ("username", None, "username@"),
|
|
|
- ("username", Some(""), "username:@"),
|
|
|
- ("username", Some("password"), "username:password@")
|
|
|
- ];
|
|
|
- for &(username, password, result) in &data {
|
|
|
- assert_eq!(UserInfoFormatter {
|
|
|
- username: username,
|
|
|
- password: password
|
|
|
- }.to_string(), result.to_string());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- #[test]
|
|
|
- fn relative_scheme_url_formatting() {
|
|
|
- let data = [
|
|
|
- ("http://example.com/", "http://example.com/"),
|
|
|
- ("http://addslash.com", "http://addslash.com/"),
|
|
|
- ("http://@emptyuser.com/", "http://emptyuser.com/"),
|
|
|
- ("http://:@emptypass.com/", "http://:@emptypass.com/"),
|
|
|
- ("http://user@user.com/", "http://user@user.com/"),
|
|
|
- ("http://user:pass@userpass.com/", "http://user:pass@userpass.com/"),
|
|
|
- ("http://slashquery.com/path/?q=something", "http://slashquery.com/path/?q=something"),
|
|
|
- ("http://noslashquery.com/path?q=something", "http://noslashquery.com/path?q=something")
|
|
|
- ];
|
|
|
- for &(input, result) in &data {
|
|
|
- let url = Url::parse(input).unwrap();
|
|
|
- assert_eq!(url.to_string(), result.to_string());
|
|
|
- }
|
|
|
- }
|
|
|
-}
|