mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Rustfmt net crate
This commit is contained in:
parent
ba1ed11ced
commit
2481ad25f8
30 changed files with 4957 additions and 2870 deletions
|
@ -21,7 +21,13 @@ fn test_exit() {
|
|||
let (mtx, _mrx) = ipc::channel().unwrap();
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
let (resource_thread, _private_resource_thread) = new_core_resource_thread(
|
||||
"".into(), None, ProfilerChan(tx), MemProfilerChan(mtx), create_embedder_proxy(), None);
|
||||
"".into(),
|
||||
None,
|
||||
ProfilerChan(tx),
|
||||
MemProfilerChan(mtx),
|
||||
create_embedder_proxy(),
|
||||
None,
|
||||
);
|
||||
resource_thread.send(CoreResourceMsg::Exit(sender)).unwrap();
|
||||
receiver.recv().unwrap();
|
||||
}
|
||||
|
@ -32,12 +38,16 @@ fn test_parse_hostsfile() {
|
|||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
assert_eq!(
|
||||
ip("127.0.0.2"),
|
||||
*hosts_table.get("servo.test.server").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_malformed_hostsfile() {
|
||||
let mock_hosts_file_content = "malformed file\n127.0.0.1 foo.bar.com\nservo.test.server 127.0.0.1";
|
||||
let mock_hosts_file_content =
|
||||
"malformed file\n127.0.0.1 foo.bar.com\nservo.test.server 127.0.0.1";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(1, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
|
@ -45,7 +55,8 @@ fn test_parse_malformed_hostsfile() {
|
|||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_line_comment() {
|
||||
let mock_hosts_file_content = "# this is a line comment\n127.0.0.1 foo.bar.com\n# anothercomment";
|
||||
let mock_hosts_file_content =
|
||||
"# this is a line comment\n127.0.0.1 foo.bar.com\n# anothercomment";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(1, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
|
@ -53,11 +64,15 @@ fn test_parse_hostsfile_with_line_comment() {
|
|||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_end_of_line_comment() {
|
||||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com # line ending comment\n127.0.0.2 servo.test.server #comment";
|
||||
let mock_hosts_file_content =
|
||||
"127.0.0.1 foo.bar.com # line ending comment\n127.0.0.2 servo.test.server #comment";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
assert_eq!(
|
||||
ip("127.0.0.2"),
|
||||
*hosts_table.get("servo.test.server").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -86,12 +101,14 @@ fn test_parse_hostsfile_with_tabs_instead_spaces() {
|
|||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(2, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
assert_eq!(
|
||||
ip("127.0.0.2"),
|
||||
*hosts_table.get("servo.test.server").unwrap()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_valid_ipv4_addresses()
|
||||
{
|
||||
fn test_parse_hostsfile_with_valid_ipv4_addresses() {
|
||||
let mock_hosts_file_content =
|
||||
"255.255.255.255 foo.bar.com\n169.0.1.201 servo.test.server\n192.168.5.0 servo.foo.com";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
|
@ -99,8 +116,7 @@ fn test_parse_hostsfile_with_valid_ipv4_addresses()
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_invalid_ipv4_addresses()
|
||||
{
|
||||
fn test_parse_hostsfile_with_invalid_ipv4_addresses() {
|
||||
let mock_hosts_file_content = "256.255.255.255 foo.bar.com\n169.0.1000.201 servo.test.server \
|
||||
\n192.168.5.500 servo.foo.com\n192.abc.100.2 test.servo.com";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
|
@ -108,8 +124,7 @@ fn test_parse_hostsfile_with_invalid_ipv4_addresses()
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_valid_ipv6_addresses()
|
||||
{
|
||||
fn test_parse_hostsfile_with_valid_ipv6_addresses() {
|
||||
let mock_hosts_file_content = "2001:0db8:0000:0000:0000:ff00:0042:8329 foo.bar.com\n\
|
||||
2001:db8:0:0:0:ff00:42:8329 moz.foo.com\n\
|
||||
2001:db8::ff00:42:8329 foo.moz.com moz.moz.com\n\
|
||||
|
@ -122,8 +137,7 @@ fn test_parse_hostsfile_with_valid_ipv6_addresses()
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_invalid_ipv6_addresses()
|
||||
{
|
||||
fn test_parse_hostsfile_with_invalid_ipv6_addresses() {
|
||||
let mock_hosts_file_content = "12001:0db8:0000:0000:0000:ff00:0042:8329 foo.bar.com\n\
|
||||
2001:zdb8:0:0:0:gg00:42:t329 moz.foo.com\n\
|
||||
2002:0DB8:85A3:0042:1000:8A2E:0370:7334/1289 baz3.bar.moz";
|
||||
|
@ -132,14 +146,19 @@ fn test_parse_hostsfile_with_invalid_ipv6_addresses()
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_hostsfile_with_end_of_line_whitespace()
|
||||
{
|
||||
fn test_parse_hostsfile_with_end_of_line_whitespace() {
|
||||
let mock_hosts_file_content = "127.0.0.1 foo.bar.com \n\
|
||||
2001:db8:0:0:0:ff00:42:8329 moz.foo.com\n \
|
||||
127.0.0.2 servo.test.server ";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(3, hosts_table.len());
|
||||
assert_eq!(ip("127.0.0.1"), *hosts_table.get("foo.bar.com").unwrap());
|
||||
assert_eq!(ip("2001:db8:0:0:0:ff00:42:8329"), *hosts_table.get("moz.foo.com").unwrap());
|
||||
assert_eq!(ip("127.0.0.2"), *hosts_table.get("servo.test.server").unwrap());
|
||||
assert_eq!(
|
||||
ip("2001:db8:0:0:0:ff00:42:8329"),
|
||||
*hosts_table.get("moz.foo.com").unwrap()
|
||||
);
|
||||
assert_eq!(
|
||||
ip("127.0.0.2"),
|
||||
*hosts_table.get("servo.test.server").unwrap()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue