|
@@ -259,13 +259,13 @@ fn test_form_serialize() {
|
|
|
fn issue_25() {
|
|
fn issue_25() {
|
|
|
let filename = if cfg!(windows) { r"C:\run\pg.sock" } else { "/run/pg.sock" };
|
|
let filename = if cfg!(windows) { r"C:\run\pg.sock" } else { "/run/pg.sock" };
|
|
|
let mut url = Url::from_file_path(filename).unwrap();
|
|
let mut url = Url::from_file_path(filename).unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
url.set_scheme("postgres").unwrap();
|
|
url.set_scheme("postgres").unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
url.set_host(Some("")).unwrap();
|
|
url.set_host(Some("")).unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
url.set_username("me").unwrap();
|
|
url.set_username("me").unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
let expected = format!("postgres://me@/{}run/pg.sock", if cfg!(windows) { "C:/" } else { "" });
|
|
let expected = format!("postgres://me@/{}run/pg.sock", if cfg!(windows) { "C:/" } else { "" });
|
|
|
assert_eq!(url.as_str(), expected);
|
|
assert_eq!(url.as_str(), expected);
|
|
|
}
|
|
}
|
|
@@ -277,7 +277,7 @@ fn issue_61() {
|
|
|
url.set_scheme("https").unwrap();
|
|
url.set_scheme("https").unwrap();
|
|
|
assert_eq!(url.port(), None);
|
|
assert_eq!(url.port(), None);
|
|
|
assert_eq!(url.port_or_known_default(), Some(443));
|
|
assert_eq!(url.port_or_known_default(), Some(443));
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
#[test]
|
|
@@ -285,7 +285,7 @@ fn issue_61() {
|
|
|
/// https://github.com/servo/rust-url/issues/197
|
|
/// https://github.com/servo/rust-url/issues/197
|
|
|
fn issue_197() {
|
|
fn issue_197() {
|
|
|
let mut url = Url::from_file_path("/").expect("Failed to parse path");
|
|
let mut url = Url::from_file_path("/").expect("Failed to parse path");
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
assert_eq!(url, Url::parse("file:///").expect("Failed to parse path + protocol"));
|
|
assert_eq!(url, Url::parse("file:///").expect("Failed to parse path + protocol"));
|
|
|
url.path_segments_mut().expect("path_segments_mut").pop_if_empty();
|
|
url.path_segments_mut().expect("path_segments_mut").pop_if_empty();
|
|
|
}
|
|
}
|
|
@@ -299,9 +299,9 @@ fn issue_241() {
|
|
|
/// https://github.com/servo/rust-url/issues/222
|
|
/// https://github.com/servo/rust-url/issues/222
|
|
|
fn append_trailing_slash() {
|
|
fn append_trailing_slash() {
|
|
|
let mut url: Url = "http://localhost:6767/foo/bar?a=b".parse().unwrap();
|
|
let mut url: Url = "http://localhost:6767/foo/bar?a=b".parse().unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
url.path_segments_mut().unwrap().push("");
|
|
url.path_segments_mut().unwrap().push("");
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar/?a=b");
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar/?a=b");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -310,10 +310,10 @@ fn append_trailing_slash() {
|
|
|
fn extend_query_pairs_then_mutate() {
|
|
fn extend_query_pairs_then_mutate() {
|
|
|
let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap();
|
|
let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap();
|
|
|
url.query_pairs_mut().extend_pairs(vec![ ("auth", "my-token") ].into_iter());
|
|
url.query_pairs_mut().extend_pairs(vec![ ("auth", "my-token") ].into_iter());
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?auth=my-token");
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?auth=my-token");
|
|
|
url.path_segments_mut().unwrap().push("some_other_path");
|
|
url.path_segments_mut().unwrap().push("some_other_path");
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar/some_other_path?auth=my-token");
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar/some_other_path?auth=my-token");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -321,9 +321,9 @@ fn extend_query_pairs_then_mutate() {
|
|
|
/// https://github.com/servo/rust-url/issues/222
|
|
/// https://github.com/servo/rust-url/issues/222
|
|
|
fn append_empty_segment_then_mutate() {
|
|
fn append_empty_segment_then_mutate() {
|
|
|
let mut url: Url = "http://localhost:6767/foo/bar?a=b".parse().unwrap();
|
|
let mut url: Url = "http://localhost:6767/foo/bar?a=b".parse().unwrap();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
url.path_segments_mut().unwrap().push("").pop();
|
|
url.path_segments_mut().unwrap().push("").pop();
|
|
|
- url.assert_invariants();
|
|
|
|
|
|
|
+ url.check_invariants().unwrap();
|
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?a=b");
|
|
assert_eq!(url.to_string(), "http://localhost:6767/foo/bar?a=b");
|
|
|
}
|
|
}
|
|
|
|
|
|