Grab bag of miscellaneous fixes

This commit is contained in:
Victor Song 2022-09-30 23:50:31 -04:00
parent 72b2119a34
commit eba3646b83
11 changed files with 27 additions and 27 deletions

View File

@ -295,7 +295,7 @@ mod test {
mod ignore_patterns { mod ignore_patterns {
use super::*; use super::*;
use std::iter::FromIterator; use std::iter::FromIterator;
use glob;
fn pat(string: &'static str) -> glob::Pattern { fn pat(string: &'static str) -> glob::Pattern {
glob::Pattern::new(string).unwrap() glob::Pattern::new(string).unwrap()

View File

@ -228,14 +228,14 @@ pub mod test {
/// both, then both should resolve to the same result. /// both, then both should resolve to the same result.
/// ///
/// It returns a vector with one or two elements in. /// It returns a vector with one or two elements in.
/// These elements can then be tested with assert_eq or what have you. /// These elements can then be tested with `assert_eq` or what have you.
pub fn parse_for_test<T, F>(inputs: &[&str], args: &'static [&'static Arg], strictnesses: Strictnesses, get: F) -> Vec<T> pub fn parse_for_test<T, F>(inputs: &[&str], args: &'static [&'static Arg], strictnesses: Strictnesses, get: F) -> Vec<T>
where F: Fn(&MatchedFlags<'_>) -> T where F: Fn(&MatchedFlags<'_>) -> T
{ {
use self::Strictnesses::*; use self::Strictnesses::*;
use crate::options::parser::{Args, Strictness}; use crate::options::parser::{Args, Strictness};
let bits = inputs.into_iter().map(OsStr::new).collect::<Vec<_>>(); let bits = inputs.iter().map(OsStr::new).collect::<Vec<_>>();
let mut result = Vec::new(); let mut result = Vec::new();
if strictnesses == Last || strictnesses == Both { if strictnesses == Last || strictnesses == Both {

View File

@ -130,18 +130,18 @@ mod terminal_test {
impl MockVars { impl MockVars {
fn empty() -> MockVars { fn empty() -> MockVars {
return MockVars { MockVars {
ls: "", ls: "",
exa: "", exa: "",
no_color: "", no_color: "",
}; }
} }
fn with_no_color() -> MockVars { fn with_no_color() -> MockVars {
return MockVars { MockVars {
ls: "", ls: "",
exa: "", exa: "",
no_color: "true", no_color: "true",
}; }
} }
} }

View File

@ -378,7 +378,7 @@ mod test {
($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => { ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => {
/// Special macro for testing Err results. /// Special macro for testing Err results.
/// This is needed because sometimes the Ok type doesnt implement PartialEq. /// This is needed because sometimes the Ok type doesnt implement `PartialEq`.
#[test] #[test]
fn $name() { fn $name() {
for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) { for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {
@ -389,7 +389,7 @@ mod test {
($name:ident: $type:ident <- $inputs:expr; $stricts:expr => like $pat:pat) => { ($name:ident: $type:ident <- $inputs:expr; $stricts:expr => like $pat:pat) => {
/// More general macro for testing against a pattern. /// More general macro for testing against a pattern.
/// Instead of using PartialEq, this just tests if it matches a pat. /// Instead of using `PartialEq`, this just tests if it matches a pat.
#[test] #[test]
fn $name() { fn $name() {
for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) { for result in parse_for_test($inputs.as_ref(), TEST_ARGS, $stricts, |mf| $type::deduce(mf)) {

View File

@ -43,7 +43,7 @@ pub mod test {
let blox = f::Blocks::None; let blox = f::Blocks::None;
let expected = TextCell::blank(Green.italic()); let expected = TextCell::blank(Green.italic());
assert_eq!(expected, blox.render(&TestColours).into()); assert_eq!(expected, blox.render(&TestColours));
} }
@ -52,6 +52,6 @@ pub mod test {
let blox = f::Blocks::Some(3005); let blox = f::Blocks::Some(3005);
let expected = TextCell::paint_str(Red.blink(), "3005"); let expected = TextCell::paint_str(Red.blink(), "3005");
assert_eq!(expected, blox.render(&TestColours).into()); assert_eq!(expected, blox.render(&TestColours));
} }
} }

View File

@ -85,7 +85,7 @@ pub mod test {
].into(), ].into(),
}; };
assert_eq!(expected, stati.render(&TestColours).into()) assert_eq!(expected, stati.render(&TestColours))
} }
@ -104,6 +104,6 @@ pub mod test {
].into(), ].into(),
}; };
assert_eq!(expected, stati.render(&TestColours).into()) assert_eq!(expected, stati.render(&TestColours))
} }
} }

View File

@ -21,8 +21,8 @@ pub mod test {
#[test] #[test]
fn blocklessness() { fn blocklessness() {
let io = f::Inode(1414213); let io = f::Inode(1_414_213);
let expected = TextCell::paint_str(Cyan.underline(), "1414213"); let expected = TextCell::paint_str(Cyan.underline(), "1414213");
assert_eq!(expected, io.render(Cyan.underline()).into()); assert_eq!(expected, io.render(Cyan.underline()));
} }
} }

View File

@ -52,7 +52,7 @@ pub mod test {
contents: vec![ Blue.paint("1") ].into(), contents: vec![ Blue.paint("1") ].into(),
}; };
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into()); assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
} }
#[test] #[test]
@ -67,7 +67,7 @@ pub mod test {
contents: vec![ Blue.paint("3,005") ].into(), contents: vec![ Blue.paint("3,005") ].into(),
}; };
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into()); assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
} }
#[test] #[test]
@ -82,6 +82,6 @@ pub mod test {
contents: vec![ Blue.on(Red).paint("3,005") ].into(), contents: vec![ Blue.on(Red).paint("3,005") ].into(),
}; };
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into()); assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
} }
} }

View File

@ -40,7 +40,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0755"); let expected = TextCell::paint_str(Purple.bold(), "0755");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
#[test] #[test]
@ -54,7 +54,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0644"); let expected = TextCell::paint_str(Purple.bold(), "0644");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
#[test] #[test]
@ -68,7 +68,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0600"); let expected = TextCell::paint_str(Purple.bold(), "0600");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
#[test] #[test]
@ -82,7 +82,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "4777"); let expected = TextCell::paint_str(Purple.bold(), "4777");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
@ -97,7 +97,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "2777"); let expected = TextCell::paint_str(Purple.bold(), "2777");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
#[test] #[test]
@ -111,6 +111,6 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits }; let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "1777"); let expected = TextCell::paint_str(Purple.bold(), "1777");
assert_eq!(expected, octal.render(Purple.bold()).into()); assert_eq!(expected, octal.render(Purple.bold()));
} }
} }

View File

@ -153,7 +153,7 @@ pub mod test {
#[test] #[test]
fn file_bytes() { fn file_bytes() {
let directory = f::Size::Some(1048576); let directory = f::Size::Some(1_048_576);
let expected = TextCell { let expected = TextCell {
width: DisplayWidth::from(9), width: DisplayWidth::from(9),
contents: vec![ contents: vec![

View File

@ -253,7 +253,7 @@ mod iter_test {
#[test] #[test]
fn test_iteration() { fn test_iteration() {
let foos = &[ "first", "middle", "last" ]; let foos = &[ "first", "middle", "last" ];
let mut iter = TreeDepth::root().iterate_over(foos.into_iter()); let mut iter = TreeDepth::root().iterate_over(foos.iter());
let next = iter.next().unwrap(); let next = iter.next().unwrap();
assert_eq!(&"first", next.1); assert_eq!(&"first", next.1);
@ -273,7 +273,7 @@ mod iter_test {
#[test] #[test]
fn test_empty() { fn test_empty() {
let nothing: &[usize] = &[]; let nothing: &[usize] = &[];
let mut iter = TreeDepth::root().iterate_over(nothing.into_iter()); let mut iter = TreeDepth::root().iterate_over(nothing.iter());
assert!(iter.next().is_none()); assert!(iter.next().is_none());
} }
} }