Skip to content

Commit e00acb2

Browse files
committed
Test for existing (old) log_violation_syntax interface
1 parent 0f0813f commit e00acb2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/unit.rs

Lines changed: 15 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,17 @@ 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 = {
486+
let vfn = |s: &str| violation.set(Some(s.to_owned()));
487+
let options = Url::options().log_syntax_violation(Some(&vfn));
488+
options.parse("http:////mozilla.org:42").unwrap()
489+
};
490+
assert_eq!(url.port(), Some(42));
491+
492+
let violation = violation.take();
493+
assert_eq!(violation, Some("expected //".to_string()));
494+
}

0 commit comments

Comments
 (0)