summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Otto <th1000s@posteo.net>2021-12-06 23:56:43 +0100
committerDan Davison <dandavison7@gmail.com>2021-12-07 19:18:23 -0500
commite5eea75eee78bf66d16ff36fe41a1bd4032381b3 (patch)
treebde916d7b8a3e3c0fddab82dae164e8377157e64
parent91b8c3066cca13d5d6fe952e449e23c5750355ca (diff)
Fixed some test clippys
Note that currently `cargo clippy --tests` is not checked by the CI runs
-rw-r--r--src/utils/process.rs24
-rw-r--r--src/wrapping.rs36
2 files changed, 30 insertions, 30 deletions
diff --git a/src/utils/process.rs b/src/utils/process.rs
index 65796808..9dcee8d4 100644
--- a/src/utils/process.rs
+++ b/src/utils/process.rs
@@ -30,7 +30,7 @@ pub fn calling_process() -> Option<Cow<'static, CallingProcess>> {
}
#[cfg(test)]
{
- determine_calling_process().map(|proc| Cow::Owned(proc))
+ determine_calling_process().map(Cow::Owned)
}
}
@@ -487,10 +487,10 @@ pub mod tests {
pub struct FakeParentArgs {}
impl FakeParentArgs {
pub fn once(args: &str) -> Self {
- Self::new(args, |v| TlsState::Once(v), "once")
+ Self::new(args, TlsState::Once, "once")
}
pub fn for_scope(args: &str) -> Self {
- Self::new(args, |v| TlsState::Scope(v), "for_scope")
+ Self::new(args, TlsState::Scope, "for_scope")
}
fn new<F>(args: &str, initial: F, from_: &str) -> Self
where
@@ -665,7 +665,7 @@ pub mod tests {
MockProcInfo {
delta_pid: processes.last().map(|p| p.0).unwrap_or(1),
info: processes
- .into_iter()
+ .iter()
.map(|(pid, start_time, cmd, ppid)| {
let cmd_vec = cmd.split(' ').map(str::to_owned).collect();
(*pid, FakeProc::new(*pid, *start_time, cmd_vec, *ppid))
@@ -700,21 +700,21 @@ pub mod tests {
#[test]
fn test_process_testing() {
{
- let _args = FakeParentArgs::once(&"git blame hello");
+ let _args = FakeParentArgs::once("git blame hello");
assert_eq!(
calling_process_cmdline(ProcInfo::new(), guess_git_blame_filename_extension),
Some("hello".into())
);
}
{
- let _args = FakeParentArgs::once(&"git blame world.txt");
+ let _args = FakeParentArgs::once("git blame world.txt");
assert_eq!(
calling_process_cmdline(ProcInfo::new(), guess_git_blame_filename_extension),
Some("txt".into())
);
}
{
- let _args = FakeParentArgs::for_scope(&"git blame hello world.txt");
+ let _args = FakeParentArgs::for_scope("git blame hello world.txt");
assert_eq!(
calling_process_cmdline(ProcInfo::new(), guess_git_blame_filename_extension),
Some("txt".into())
@@ -730,7 +730,7 @@ pub mod tests {
#[test]
#[should_panic]
fn test_process_testing_assert() {
- let _args = FakeParentArgs::once(&"git blame do.not.panic");
+ let _args = FakeParentArgs::once("git blame do.not.panic");
assert_eq!(
calling_process_cmdline(ProcInfo::new(), guess_git_blame_filename_extension),
Some("panic".into())
@@ -742,7 +742,7 @@ pub mod tests {
#[test]
#[should_panic]
fn test_process_testing_assert_never_used() {
- let _args = FakeParentArgs::once(&"never used");
+ let _args = FakeParentArgs::once("never used");
// causes a panic while panicing, so can't test:
// let _args = FakeParentArgs::for_scope(&"never used");
@@ -751,7 +751,7 @@ pub mod tests {
#[test]
fn test_process_testing_scope_can_remain_unused() {
- let _args = FakeParentArgs::for_scope(&"never used");
+ let _args = FakeParentArgs::for_scope("never used");
}
#[test]
@@ -924,7 +924,7 @@ pub mod tests {
]);
assert_eq!(
calling_process_cmdline(parent, describe_calling_process),
- Some(CallingProcess::GitGrep(empty_command_line.clone()))
+ Some(CallingProcess::GitGrep(empty_command_line))
);
for grep_command in &[
@@ -1003,7 +1003,7 @@ pub mod tests {
assert_eq!(cmd_line.short_options, set(&["-w"]));
assert_eq!(ext, Some(expected_extension.to_string()));
} else {
- assert!(false);
+ unreachable!();
}
}
}
diff --git a/src/wrapping.rs b/src/wrapping.rs
index 1a652834..e600ccc4 100644
--- a/src/wrapping.rs
+++ b/src/wrapping.rs
@@ -575,9 +575,9 @@ mod tests {
static ref SD: Style = Style::default();
}
- const W: &str = &"+"; // wrap
- const WR: &str = &"<"; // wrap-right
- const RA: &str = &">"; // right-align
+ const W: &str = "+"; // wrap
+ const WR: &str = "<"; // wrap-right
+ const RA: &str = ">"; // right-align
lazy_static! {
static ref WRAP_DEFAULT_ARGS: Vec<&'static str> = vec![
@@ -606,7 +606,7 @@ mod tests {
}
fn mk_wrap_cfg(wrap_cfg: &WrapConfig) -> Config {
- let mut cfg: Config = Config::from(make_config_from_args(&[]));
+ let mut cfg: Config = make_config_from_args(&[]);
cfg.wrap_config = wrap_cfg.clone();
cfg
}
@@ -617,7 +617,7 @@ mod tests {
<I as IntoIterator>::IntoIter: DoubleEndedIterator,
S: Copy + Default + std::fmt::Debug,
{
- wrap_line(&cfg, line, line_width, &S::default(), &None)
+ wrap_line(cfg, line, line_width, &S::default(), &None)
}
#[test]
@@ -732,7 +732,7 @@ mod tests {
}
#[test]
- fn test_wrap_line_newlines<'a>() {
+ fn test_wrap_line_newlines() {
fn mk_input(len: usize) -> LineSections<'static, Style> {
const IN: &str = "0123456789abcdefZ";
let v = &[*S1, *S2];
@@ -785,10 +785,10 @@ mod tests {
let line = mk_input_nl(9);
let lines = wrap_test(&cfg, line, 3);
let expected = mk_input_nl(9);
- let line1 = mk_expected(&expected, 0, 2, Some((*SD, &W)));
- let line2 = mk_expected(&expected, 2, 4, Some((*SD, &W)));
- let line3 = mk_expected(&expected, 4, 6, Some((*SD, &W)));
- let line4 = mk_expected(&expected, 6, 8, Some((*SD, &W)));
+ let line1 = mk_expected(&expected, 0, 2, Some((*SD, W)));
+ let line2 = mk_expected(&expected, 2, 4, Some((*SD, W)));
+ let line3 = mk_expected(&expected, 4, 6, Some((*SD, W)));
+ let line4 = mk_expected(&expected, 6, 8, Some((*SD, W)));
let line5 = mk_expected(&expected, 8, 11, None);
assert_eq!(lines, vec![line1, line2, line3, line4, line5]);
}
@@ -797,10 +797,10 @@ mod tests {
let line = mk_input_nl(10);
let lines = wrap_test(&cfg, line, 3);
let expected = mk_input_nl(10);
- let line1 = mk_expected(&expected, 0, 2, Some((*SD, &W)));
- let line2 = mk_expected(&expected, 2, 4, Some((*SD, &W)));
- let line3 = mk_expected(&expected, 4, 6, Some((*SD, &W)));
- let line4 = mk_expected(&expected, 6, 8, Some((*SD, &W)));
+ let line1 = mk_expected(&expected, 0, 2, Some((*SD, W)));
+ let line2 = mk_expected(&expected, 2, 4, Some((*SD, W)));
+ let line3 = mk_expected(&expected, 4, 6, Some((*SD, W)));
+ let line4 = mk_expected(&expected, 6, 8, Some((*SD, W)));
let line5 = mk_expected(&expected, 8, 11, Some((*S2, "\n")));
assert_eq!(lines, vec![line1, line2, line3, line4, line5]);
}
@@ -844,8 +844,8 @@ mod tests {
assert_eq!(
lines,
vec![
- vec![(*S1, "abc"), (*SD, &W)],
- vec![(*S2, "mnö̲"), (*SD, &W)],
+ vec![(*S1, "abc"), (*SD, W)],
+ vec![(*S2, "mnö̲"), (*SD, W)],
vec![(*S1, "xyz")]
]
);
@@ -856,8 +856,8 @@ mod tests {
assert_eq!(
lines,
vec![
- vec![(*S1, "abc"), (*SD, &W)],
- vec![(*S2, "deநி"), (*SD, &W)],
+ vec![(*S1, "abc"), (*SD, W)],
+ vec![(*S2, "deநி"), (*SD, W)],
vec![(*S1, "ghij")]
]
);