Skip to content

Commit 4627753

Browse files
committed
ci: Add tests for stringy roundtrip of URL params
1 parent 9771ab5 commit 4627753

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

url/tests/unit.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,3 +1392,25 @@ fn test_parse_url_with_single_byte_control_host() {
13921392
let url2 = Url::parse(url1.as_str()).unwrap();
13931393
assert_eq!(url2, url1);
13941394
}
1395+
1396+
#[test]
1397+
fn magnet_roundtrip_parse() {
1398+
let url = Url::parse("magnet:?xt=urn:btmh:foo").unwrap();
1399+
assert_eq!(url.as_str(), "magnet:?xt=urn:btmh:foo");
1400+
}
1401+
1402+
#[test]
1403+
fn magnet_roundtrip_append_pair() {
1404+
let mut url = Url::parse("magnet:").unwrap();
1405+
{
1406+
let mut query_pairs = url.query_pairs_mut();
1407+
query_pairs.append_pair("xt", "urn:btmh:foo");
1408+
}
1409+
assert_eq!(url.as_str(), "magnet:?xt=urn:btmh:foo");
1410+
}
1411+
1412+
#[test]
1413+
fn magnet_roundtrip_parse_with_params() {
1414+
let url = Url::parse_with_params("magnet:", vec![("xt", "urn:btmh:foo")]).unwrap();
1415+
assert_eq!(url.as_str(), "magnet:?xt=urn:btmh:foo");
1416+
}

0 commit comments

Comments
 (0)