|
|
@@ -13,6 +13,7 @@ extern crate url;
|
|
|
|
|
|
use std::ascii::AsciiExt;
|
|
|
use std::borrow::Cow;
|
|
|
+use std::cell::Cell;
|
|
|
use std::net::{Ipv4Addr, Ipv6Addr};
|
|
|
use std::path::{Path, PathBuf};
|
|
|
use url::{Host, HostAndPort, Url, form_urlencoded};
|
|
|
@@ -477,3 +478,15 @@ fn test_windows_unc_path() {
|
|
|
let url = Url::from_file_path(Path::new(r"\\.\some\path\file.txt"));
|
|
|
assert!(url.is_err());
|
|
|
}
|
|
|
+
|
|
|
+#[test]
|
|
|
+fn test_old_log_violation_option() {
|
|
|
+ let violation = Cell::new(None);
|
|
|
+ let url = Url::options()
|
|
|
+ .log_syntax_violation(Some(&|s| violation.set(Some(s.to_owned()))))
|
|
|
+ .parse("http:////mozilla.org:42").unwrap();
|
|
|
+ assert_eq!(url.port(), Some(42));
|
|
|
+
|
|
|
+ let violation = violation.take();
|
|
|
+ assert_eq!(violation, Some("expected //".to_string()));
|
|
|
+}
|