Skip to content

Commit 42b82fa

Browse files
committed
Test for existing log_violation_syntax interface
1 parent 0f0813f commit 42b82fa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/unit.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ extern crate url;
1313

1414
use std::ascii::AsciiExt;
1515
use std::borrow::Cow;
16+
use std::cell::Cell;
1617
use std::net::{Ipv4Addr, Ipv6Addr};
1718
use std::path::{Path, PathBuf};
1819
use url::{Host, HostAndPort, Url, form_urlencoded};
@@ -477,3 +478,15 @@ fn test_windows_unc_path() {
477478
let url = Url::from_file_path(Path::new(r"\\.\some\path\file.txt"));
478479
assert!(url.is_err());
479480
}
481+
482+
#[test]
483+
fn test_old_log_violation_option() {
484+
let violation = Cell::new(None);
485+
let url = Url::options()
486+
.log_syntax_violation(Some(&|s| violation.set(Some(s.to_owned()))))
487+
.parse("http:////mozilla.org:42").unwrap();
488+
assert_eq!(url.port(), Some(42));
489+
490+
let violation = violation.take();
491+
assert_eq!(violation, Some("expected //".to_string()));
492+
}

0 commit comments

Comments
 (0)