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 {
use super::*;
use std::iter::FromIterator;
use glob;
fn pat(string: &'static str) -> glob::Pattern {
glob::Pattern::new(string).unwrap()

View File

@ -228,14 +228,14 @@ pub mod test {
/// both, then both should resolve to the same result.
///
/// 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>
where F: Fn(&MatchedFlags<'_>) -> T
{
use self::Strictnesses::*;
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();
if strictnesses == Last || strictnesses == Both {

View File

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

View File

@ -378,7 +378,7 @@ mod test {
($name:ident: $type:ident <- $inputs:expr; $stricts:expr => err $result:expr) => {
/// 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]
fn $name() {
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) => {
/// 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]
fn $name() {
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 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 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(),
};
assert_eq!(expected, stati.render(&TestColours).into())
assert_eq!(expected, stati.render(&TestColours))
}
@ -104,6 +104,6 @@ pub mod test {
].into(),
};
assert_eq!(expected, stati.render(&TestColours).into())
assert_eq!(expected, stati.render(&TestColours))
}
}

View File

@ -21,8 +21,8 @@ pub mod test {
#[test]
fn blocklessness() {
let io = f::Inode(1414213);
let io = f::Inode(1_414_213);
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(),
};
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()).into());
assert_eq!(expected, stati.render(&TestColours, &locale::Numeric::english()));
}
#[test]
@ -67,7 +67,7 @@ pub mod test {
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]
@ -82,6 +82,6 @@ pub mod test {
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 expected = TextCell::paint_str(Purple.bold(), "0755");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -54,7 +54,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0644");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -68,7 +68,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
let expected = TextCell::paint_str(Purple.bold(), "0600");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -82,7 +82,7 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
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 expected = TextCell::paint_str(Purple.bold(), "2777");
assert_eq!(expected, octal.render(Purple.bold()).into());
assert_eq!(expected, octal.render(Purple.bold()));
}
#[test]
@ -111,6 +111,6 @@ pub mod test {
let octal = f::OctalPermissions{ permissions: bits };
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]
fn file_bytes() {
let directory = f::Size::Some(1048576);
let directory = f::Size::Some(1_048_576);
let expected = TextCell {
width: DisplayWidth::from(9),
contents: vec![

View File

@ -253,7 +253,7 @@ mod iter_test {
#[test]
fn test_iteration() {
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();
assert_eq!(&"first", next.1);
@ -273,7 +273,7 @@ mod iter_test {
#[test]
fn test_empty() {
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());
}
}