Add tests for UrlString methods (#10256)

This commit is contained in:
Charlie Marsh
2024-12-31 14:16:08 -05:00
committed by GitHub
parent cf88828e55
commit 9ebd94cb93
+32
View File
@@ -275,3 +275,35 @@ pub enum ToUrlError {
path: String,
},
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn base_str() {
let url = UrlString("https://example.com/path?query#fragment".to_string());
assert_eq!(url.base_str(), "https://example.com/path");
let url = UrlString("https://example.com/path#fragment".to_string());
assert_eq!(url.base_str(), "https://example.com/path");
let url = UrlString("https://example.com/path".to_string());
assert_eq!(url.base_str(), "https://example.com/path");
}
#[test]
fn without_fragment() {
let url = UrlString("https://example.com/path?query#fragment".to_string());
assert_eq!(
url.without_fragment(),
UrlString("https://example.com/path?query".to_string())
);
let url = UrlString("https://example.com/path#fragment".to_string());
assert_eq!(url.base_str(), "https://example.com/path");
let url = UrlString("https://example.com/path".to_string());
assert_eq!(url.base_str(), "https://example.com/path");
}
}