mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-25 20:12:14 +03:00
Fix clippy warnings
This commit is contained in:
parent
1ddda4c86b
commit
da233dbd7a
@ -41,7 +41,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn eval_html_escape() {
|
fn eval_html_escape() {
|
||||||
let tests = vec![
|
let tests = [
|
||||||
("foo", "foo"),
|
("foo", "foo"),
|
||||||
("<tag>", "<tag>"),
|
("<tag>", "<tag>"),
|
||||||
("foo & bar", "foo & bar"),
|
("foo & bar", "foo & bar"),
|
||||||
|
@ -684,7 +684,7 @@ fn get_redirect_url(location: &str, base_url: &str) -> String {
|
|||||||
fn get_redirect_method(response_status: u32, original_method: Method) -> Method {
|
fn get_redirect_method(response_status: u32, original_method: Method) -> Method {
|
||||||
// This replicates curl's behavior
|
// This replicates curl's behavior
|
||||||
match response_status {
|
match response_status {
|
||||||
301 | 302 | 303 => Method("GET".to_string()),
|
301..=303 => Method("GET".to_string()),
|
||||||
// Could be only 307 and 308, but curl does this for all 3xx
|
// Could be only 307 and 308, but curl does this for all 3xx
|
||||||
// codes not converted to GET above.
|
// codes not converted to GET above.
|
||||||
_ => original_method,
|
_ => original_method,
|
||||||
|
@ -264,7 +264,7 @@ pub mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncompress_brotli() {
|
fn test_uncompress_brotli() {
|
||||||
let data = vec![
|
let data = [
|
||||||
0x21, 0x2c, 0x00, 0x04, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c,
|
0x21, 0x2c, 0x00, 0x04, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c,
|
||||||
0x64, 0x21, 0x03,
|
0x64, 0x21, 0x03,
|
||||||
];
|
];
|
||||||
@ -273,7 +273,7 @@ pub mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncompress_gzip() {
|
fn test_uncompress_gzip() {
|
||||||
let data = vec![
|
let data = [
|
||||||
0x1f, 0x8b, 0x08, 0x08, 0xa7, 0x52, 0x85, 0x5f, 0x00, 0x03, 0x64, 0x61, 0x74, 0x61,
|
0x1f, 0x8b, 0x08, 0x08, 0xa7, 0x52, 0x85, 0x5f, 0x00, 0x03, 0x64, 0x61, 0x74, 0x61,
|
||||||
0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f,
|
0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f,
|
||||||
0xca, 0x49, 0x51, 0x04, 0x00, 0xa3, 0x1c, 0x29, 0x1c, 0x0c, 0x00, 0x00, 0x00,
|
0xca, 0x49, 0x51, 0x04, 0x00, 0xa3, 0x1c, 0x29, 0x1c, 0x0c, 0x00, 0x00, 0x00,
|
||||||
@ -283,7 +283,7 @@ pub mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncompress_zlib() {
|
fn test_uncompress_zlib() {
|
||||||
let data = vec![
|
let data = [
|
||||||
0x78, 0x9c, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49, 0x51,
|
0x78, 0x9c, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49, 0x51,
|
||||||
0x04, 0x00, 0x1c, 0x49, 0x04, 0x3e,
|
0x04, 0x00, 0x1c, 0x49, 0x04, 0x3e,
|
||||||
];
|
];
|
||||||
@ -292,7 +292,7 @@ pub mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uncompress_error() {
|
fn test_uncompress_error() {
|
||||||
let data = vec![0x21];
|
let data = [0x21];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
uncompress_brotli(&data[..]).err().unwrap(),
|
uncompress_brotli(&data[..]).err().unwrap(),
|
||||||
HttpError::CouldNotUncompressResponse {
|
HttpError::CouldNotUncompressResponse {
|
||||||
|
@ -850,7 +850,7 @@ pub mod tests {
|
|||||||
value: FilterValue::HtmlEscape,
|
value: FilterValue::HtmlEscape,
|
||||||
};
|
};
|
||||||
|
|
||||||
let tests = vec![
|
let tests = [
|
||||||
("foo", "foo"),
|
("foo", "foo"),
|
||||||
("<tag>", "<tag>"),
|
("<tag>", "<tag>"),
|
||||||
("foo & bar", "foo & bar"),
|
("foo & bar", "foo & bar"),
|
||||||
@ -882,7 +882,7 @@ pub mod tests {
|
|||||||
value: FilterValue::HtmlUnescape,
|
value: FilterValue::HtmlUnescape,
|
||||||
};
|
};
|
||||||
|
|
||||||
let tests = vec![
|
let tests = [
|
||||||
("foo", "foo"),
|
("foo", "foo"),
|
||||||
("<tag>", "<tag>"),
|
("<tag>", "<tag>"),
|
||||||
("foo & bar", "foo & bar"),
|
("foo & bar", "foo & bar"),
|
||||||
|
@ -100,7 +100,7 @@ fn any_char(reader: &mut Reader) -> ParseResult<'static, (char, String, Pos)> {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
if vec!['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c) {
|
if ['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c) {
|
||||||
Err(error::Error {
|
Err(error::Error {
|
||||||
pos: start.pos,
|
pos: start.pos,
|
||||||
recoverable: true,
|
recoverable: true,
|
||||||
|
@ -1128,7 +1128,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut reader = Reader::new(r#"/a\/b/"#);
|
let mut reader = Reader::new(r"/a\/b/");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
regex(&mut reader).unwrap(),
|
regex(&mut reader).unwrap(),
|
||||||
Regex {
|
Regex {
|
||||||
@ -1136,19 +1136,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut reader = Reader::new(r#"/a\.b/"#);
|
let mut reader = Reader::new(r"/a\.b/");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
regex(&mut reader).unwrap(),
|
regex(&mut reader).unwrap(),
|
||||||
Regex {
|
Regex {
|
||||||
inner: regex::Regex::new(r#"a\.b"#).unwrap()
|
inner: regex::Regex::new(r"a\.b").unwrap()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut reader = Reader::new(r#"/\d{4}-\d{2}-\d{2}/"#);
|
let mut reader = Reader::new(r"/\d{4}-\d{2}-\d{2}/");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
regex(&mut reader).unwrap(),
|
regex(&mut reader).unwrap(),
|
||||||
Regex {
|
Regex {
|
||||||
inner: regex::Regex::new(r#"\d{4}-\d{2}-\d{2}"#).unwrap()
|
inner: regex::Regex::new(r"\d{4}-\d{2}-\d{2}").unwrap()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1237,7 +1237,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut reader = Reader::new(r#"file, tmp/filename\ with\ spaces.txt;"#);
|
let mut reader = Reader::new(r"file, tmp/filename\ with\ spaces.txt;");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
file(&mut reader).unwrap(),
|
file(&mut reader).unwrap(),
|
||||||
File {
|
File {
|
||||||
@ -1281,7 +1281,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut reader = Reader::new(r#"file, tmp/filename\ with\ unescaped .txt;"#);
|
let mut reader = Reader::new(r"file, tmp/filename\ with\ unescaped .txt;");
|
||||||
let error = file(&mut reader).err().unwrap();
|
let error = file(&mut reader).err().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
error.pos,
|
error.pos,
|
||||||
|
@ -251,7 +251,7 @@ fn any_char(except: Vec<char>, reader: &mut Reader) -> ParseResult<'static, (cha
|
|||||||
}),
|
}),
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
if except.contains(&c)
|
if except.contains(&c)
|
||||||
|| vec!['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c)
|
|| ['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c)
|
||||||
{
|
{
|
||||||
Err(Error {
|
Err(Error {
|
||||||
pos: start.pos,
|
pos: start.pos,
|
||||||
|
@ -75,7 +75,7 @@ pub fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
|
|||||||
None => break,
|
None => break,
|
||||||
Some(c) => {
|
Some(c) => {
|
||||||
if c.is_alphanumeric()
|
if c.is_alphanumeric()
|
||||||
| vec![
|
| [
|
||||||
':', '/', '.', '-', '?', '=', '&', '_', '%', '*', ',', '@',
|
':', '/', '.', '-', '?', '=', '&', '_', '%', '*', ',', '@',
|
||||||
'~', '+', '!', '$', '\'', '(', ')', ';', '[', ']',
|
'~', '+', '!', '$', '\'', '(', ')', ';', '[', ']',
|
||||||
]
|
]
|
||||||
|
@ -57,7 +57,7 @@ pub fn parse(reader: &mut Reader) -> ParseResult<'static, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid(s: &str) -> bool {
|
fn is_valid(s: &str) -> bool {
|
||||||
matches!(parser::parse(s), Ok(_))
|
parser::parse(s).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -143,7 +143,7 @@ mod test {
|
|||||||
assert_eq!(args::split(r#"AAA $'BBB'"#).unwrap(), expected);
|
assert_eq!(args::split(r#"AAA $'BBB'"#).unwrap(), expected);
|
||||||
|
|
||||||
let expected = vec!["'".to_string()];
|
let expected = vec!["'".to_string()];
|
||||||
assert_eq!(args::split(r#"$'\''"#).unwrap(), expected);
|
assert_eq!(args::split(r"$'\''").unwrap(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user