diff options
author | Narawit Rakket <narawitrakket@hotmail.com> | 2022-07-03 14:34:06 +0700 |
---|---|---|
committer | Abin Simon <abinsimon10@gmail.com> | 2022-07-04 22:54:01 +0530 |
commit | e6d30ab081cb51fe50d0ac6e372c0141891546df (patch) | |
tree | 8c20380dc90037c0cab3d0a827707f134f34e8cb | |
parent | c17938224ba6777f0351ca2da989dfc1e3588c7e (diff) |
refactor(test): replace `assert_eq` comparing `bool` with `assert`
Fix clippy lint
https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
-rw-r--r-- | src/display.rs | 9 | ||||
-rw-r--r-- | src/flags/recursion.rs | 27 | ||||
-rw-r--r-- | src/meta/date.rs | 6 | ||||
-rw-r--r-- | src/meta/filetype.rs | 4 | ||||
-rw-r--r-- | src/meta/name.rs | 10 | ||||
-rw-r--r-- | src/sort.rs | 2 |
6 files changed, 27 insertions, 31 deletions
diff --git a/src/display.rs b/src/display.rs index 2986f58..fea7b7d 100644 --- a/src/display.rs +++ b/src/display.rs @@ -512,13 +512,12 @@ mod tests { .to_string(); // check if the color is present. - assert_eq!( - true, + assert!( output.starts_with("\u{1b}[38;5;"), "{:?} should start with color", output, ); - assert_eq!(true, output.ends_with("[39m"), "reset foreground color"); + assert!(output.ends_with("[39m"), "reset foreground color"); assert_eq!(get_visible_width(&output, false), *l, "visible match"); } @@ -554,8 +553,8 @@ mod tests { .to_string(); // check if the color is present. - assert_eq!(false, output.starts_with("\u{1b}[38;5;")); - assert_eq!(false, output.ends_with("[0m")); + assert!(!output.starts_with("\u{1b}[38;5;")); + assert!(!output.ends_with("[0m")); assert_eq!(get_visible_width(&output, false), *l); } diff --git a/src/flags/recursion.rs b/src/flags/recursion.rs index 932fb34..7c75823 100644 --- a/src/flags/recursion.rs +++ b/src/flags/recursion.rs @@ -153,13 +153,10 @@ mod test { #[test] fn test_enabled_from_empty_matches_and_config() { let argv = ["lsd"]; - assert_eq!( - false, - Recursion::enabled_from( - &app::build().get_matches_from_safe(argv).unwrap(), - &Config::with_none() - ) - ); + assert!(!Recursion::enabled_from( + &app::build().get_matches_from_safe(argv).unwrap(), + &Config::with_none() + )); } #[test] @@ -170,10 +167,10 @@ mod test { enabled: Some(true), depth: None, }); - assert_eq!( - true, - Recursion::enabled_from(&app::build().get_matches_from_safe(argv).unwrap(), &c) - ); + assert!(Recursion::enabled_from( + &app::build().get_matches_from_safe(argv).unwrap(), + &c + )); } #[test] @@ -184,10 +181,10 @@ mod test { enabled: Some(false), depth: None, }); - assert_eq!( - false, - Recursion::enabled_from(&app::build().get_matches_from_safe(argv).unwrap(), &c) - ); + assert!(!Recursion::enabled_from( + &app::build().get_matches_from_safe(argv).unwrap(), + &c + )); } // The following depth_from_arg_matches tests are implemented using match expressions instead diff --git a/src/meta/date.rs b/src/meta/date.rs index d10a997..ce47e53 100644 --- a/src/meta/date.rs +++ b/src/meta/date.rs @@ -235,7 +235,7 @@ mod test { let success = cross_platform_touch(&file_path, &creation_date) .unwrap() .success(); - assert_eq!(true, success, "failed to exec touch"); + assert!(success, "failed to exec touch"); let colors = Colors::new(ThemeOption::Default); let date = Date::from(&file_path.metadata().unwrap()); @@ -260,7 +260,7 @@ mod test { let success = cross_platform_touch(&file_path, &creation_date) .unwrap() .success(); - assert_eq!(true, success, "failed to exec touch"); + assert!(success, "failed to exec touch"); let colors = Colors::new(ThemeOption::Default); let date = Date::from(&file_path.metadata().unwrap()); @@ -288,7 +288,7 @@ mod test { let success = cross_platform_touch(&file_path, &creation_date) .unwrap() .success(); - assert_eq!(true, success, "failed to exec touch"); + assert!(success, "failed to exec touch"); let colors = Colors::new(ThemeOption::Default); let date = Date::from(&file_path.metadata().unwrap()); diff --git a/src/meta/filetype.rs b/src/meta/filetype.rs index 03db33b..27b59f7 100644 --- a/src/meta/filetype.rs +++ b/src/meta/filetype.rs @@ -217,7 +217,7 @@ mod test { .status() .expect("failed to exec mkfifo") .success(); - assert_eq!(true, success, "failed to exec mkfifo"); + assert!(success, "failed to exec mkfifo"); let meta = pipe_path.metadata().expect("failed to get metas"); let colors = Colors::new(ThemeOption::NoLscolors); @@ -245,7 +245,7 @@ mod test { .status() .expect("failed to exec mknod") .success(); - assert_eq!(true, success, "failed to exec mknod"); + assert!(success, "failed to exec mknod"); let meta = char_device_path.metadata().expect("failed to get metas"); let colors = Colors::new(ThemeOption::NoLscolors); diff --git a/src/meta/name.rs b/src/meta/name.rs index b4dd926..96b4df0 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -358,7 +358,7 @@ mod test { .status() .expect("failed to exec mkfifo") .success(); - assert_eq!(true, success, "failed to exec mkfifo"); + assert!(success, "failed to exec mkfifo"); let meta = pipe_path.metadata().expect("failed to get metas"); let colors = Colors::new(color::ThemeOption::NoLscolors); @@ -506,7 +506,7 @@ mod test { }, ); - assert_eq!(true, name_a < name_z); + assert!(name_a < name_z); } #[test] @@ -529,7 +529,7 @@ mod test { }, ); - assert_eq!(true, name_a < name_z); + assert!(name_a < name_z); } #[test] @@ -552,7 +552,7 @@ mod test { }, ); - assert_eq!(true, name_1 == name_2); + assert!(name_1 == name_2); } #[test] @@ -575,7 +575,7 @@ mod test { }, ); - assert_eq!(true, name_1 == name_2); + assert!(name_1 == name_2); } #[test] diff --git a/src/sort.rs b/src/sort.rs index a80d990..0a1cd01 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -217,7 +217,7 @@ mod tests { .unwrap() .success(); - assert_eq!(true, success, "failed to change file timestamp"); + assert!(success, "failed to change file timestamp"); let meta_z = Meta::from_path(&path_z, false).expect("failed to get meta"); let mut flags = Flags::default(); |