Fix typos and use more idiomatic assertions (#7755)

I have changed `assert!(a == b)` calls to `assert_eq!(a, b)`, which give
better error messages. Similarly for `assert!(a != b)` and
`assert_ne!(a, b)`. Basically all instances were comparing primitives
(string slices or integers), so there is no loss of generality from
special-case macros,

I have also fixed a number of typos in comments, variable names, and a
few user-facing messages.
This commit is contained in:
Anton
2023-01-15 05:03:32 +03:00
committed by GitHub
parent b0b0482d71
commit 7221eb7f39
32 changed files with 143 additions and 143 deletions

View File

@ -921,21 +921,21 @@ mod test {
#[test]
fn test_pattern_from_str() {
assert!("a*b".parse::<Pattern>().unwrap().matches("a_b"));
assert!("a/**b".parse::<Pattern>().unwrap_err().pos == 4);
assert_eq!("a/**b".parse::<Pattern>().unwrap_err().pos, 4);
}
#[test]
fn test_wildcard_errors() {
assert!(Pattern::new("a/**b").unwrap_err().pos == 4);
assert!(Pattern::new("a/bc**").unwrap_err().pos == 3);
assert!(Pattern::new("a/*****").unwrap_err().pos == 4);
assert!(Pattern::new("a/b**c**d").unwrap_err().pos == 2);
assert!(Pattern::new("a**b").unwrap_err().pos == 0);
assert_eq!(Pattern::new("a/**b").unwrap_err().pos, 4);
assert_eq!(Pattern::new("a/bc**").unwrap_err().pos, 3);
assert_eq!(Pattern::new("a/*****").unwrap_err().pos, 4);
assert_eq!(Pattern::new("a/b**c**d").unwrap_err().pos, 2);
assert_eq!(Pattern::new("a**b").unwrap_err().pos, 0);
}
#[test]
fn test_glob_errors() {
assert!(glob("a/**b").err().unwrap().pos == 4);
assert_eq!(glob("a/**b").err().unwrap().pos, 4);
}
// this test assumes that there is a /root directory and that