Skip to content

Commit 7741b7c

Browse files
committed
ParseOptions reuse test
1 parent 7ff44a7 commit 7741b7c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/unit.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern crate url;
1313

1414
use std::ascii::AsciiExt;
1515
use std::borrow::Cow;
16-
use std::cell::Cell;
16+
use std::cell::{Cell, RefCell};
1717
use std::net::{Ipv4Addr, Ipv6Addr};
1818
use std::path::{Path, PathBuf};
1919
use url::{Host, HostAndPort, Url, form_urlencoded};
@@ -526,3 +526,20 @@ fn test_syntax_violation_callback_lifetimes() {
526526
assert_eq!(url.path(), "/path");
527527
assert_eq!(violation.take(), Some(Backslash));
528528
}
529+
530+
#[test]
531+
fn test_options_reuse() {
532+
use url::SyntaxViolation::*;
533+
let violations = RefCell::new(Vec::new());
534+
let vfn = |v| violations.borrow_mut().push(v);
535+
536+
let options = Url::options().
537+
syntax_violation_callback(Some(&vfn));
538+
let url = options.parse("http:////mozilla.org").unwrap();
539+
540+
let options = options.base_url(Some(&url));
541+
let url = options.parse("/sub\\path").unwrap();
542+
assert_eq!(url.as_str(), "http://mozilla.org/sub/path");
543+
assert_eq!(*violations.borrow(),
544+
vec!(ExpectedDoubleSlash, Backslash));
545+
}

0 commit comments

Comments
 (0)