aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-02-05 14:09:08 -0500
committerJesse Luehrs <doy@tozt.net>2023-02-05 14:09:08 -0500
commit0cf00851dc88ed8013a35747c803b6c83db83761 (patch)
treebcc056c47b464de63b40427ef1f33c541b06cdfb /tests
parentf77f754a6ebe8eeabaced9caaad710bac8582ab1 (diff)
downloadvt100-rust-0cf00851dc88ed8013a35747c803b6c83db83761.tar.gz
vt100-rust-0cf00851dc88ed8013a35747c803b6c83db83761.zip
clippy
Diffstat (limited to 'tests')
-rw-r--r--tests/helpers/fixtures.rs19
-rw-r--r--tests/helpers/mod.rs4
-rw-r--r--tests/quickcheck.rs5
-rw-r--r--tests/split-escapes.rs8
-rw-r--r--tests/window_contents.rs2
5 files changed, 16 insertions, 22 deletions
diff --git a/tests/helpers/fixtures.rs b/tests/helpers/fixtures.rs
index c0f8b75..bc39926 100644
--- a/tests/helpers/fixtures.rs
+++ b/tests/helpers/fixtures.rs
@@ -96,7 +96,7 @@ impl FixtureScreen {
let cell = screen.cell(row, col).unwrap();
if cell != &vt100::Cell::default() {
cells.insert(
- format!("{},{}", row, col),
+ format!("{row},{col}"),
FixtureCell::from_cell(cell),
);
}
@@ -159,8 +159,8 @@ where
{
let s = match color {
vt100::Color::Default => unreachable!(),
- vt100::Color::Idx(n) => format!("{}", n),
- vt100::Color::Rgb(r, g, b) => format!("#{:02x}{:02x}{:02x}", r, g, b),
+ vt100::Color::Idx(n) => format!("{n}"),
+ vt100::Color::Rgb(r, g, b) => format!("#{r:02x}{g:02x}{b:02x}"),
};
serializer.serialize_str(&s)
}
@@ -231,8 +231,7 @@ where
fn load_input(name: &str, i: usize) -> Option<Vec<u8>> {
let mut file = std::fs::File::open(format!(
- "tests/data/fixtures/{}/{}.typescript",
- name, i
+ "tests/data/fixtures/{name}/{i}.typescript"
))
.ok()?;
let mut input = vec![];
@@ -241,11 +240,9 @@ fn load_input(name: &str, i: usize) -> Option<Vec<u8>> {
}
fn load_screen(name: &str, i: usize) -> Option<FixtureScreen> {
- let mut file = std::fs::File::open(format!(
- "tests/data/fixtures/{}/{}.json",
- name, i
- ))
- .ok()?;
+ let mut file =
+ std::fs::File::open(format!("tests/data/fixtures/{name}/{i}.json"))
+ .ok()?;
Some(FixtureScreen::load(&mut file))
}
@@ -281,7 +278,7 @@ fn assert_produces(input: &[u8], expected: &FixtureScreen) {
for col in 0..cols {
let expected_cell = expected
.cells
- .get(&format!("{},{}", row, col))
+ .get(&format!("{row},{col}"))
.cloned()
.unwrap_or_default();
let got_cell = parser.screen().cell(row, col).unwrap();
diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs
index dc08ce5..67bb1f4 100644
--- a/tests/helpers/mod.rs
+++ b/tests/helpers/mod.rs
@@ -46,7 +46,7 @@ impl<'a> std::fmt::Debug for Bytes<'a> {
13 => f.write_str("\\r")?,
92 => f.write_str("\\\\")?,
32..=126 => f.write_str(&char::from(*c).to_string())?,
- _ => f.write_fmt(format_args!("\\x{:02x}", c))?,
+ _ => f.write_fmt(format_args!("\\x{c:02x}"))?,
}
}
f.write_str("\"")?;
@@ -267,7 +267,7 @@ pub fn format_bytes(bytes: &[u8]) -> String {
13 => v.extend(b"\\r"),
27 => v.extend(b"\\e"),
c if c < 32 || c == 127 => {
- v.extend(format!("\\x{:02x}", c).as_bytes())
+ v.extend(format!("\\x{c:02x}").as_bytes())
}
b => v.push(b),
}
diff --git a/tests/quickcheck.rs b/tests/quickcheck.rs
index efb6f63..3591285 100644
--- a/tests/quickcheck.rs
+++ b/tests/quickcheck.rs
@@ -13,8 +13,7 @@ impl quickcheck::Arbitrary for TerminalInput {
};
TerminalInput(
(0..size)
- .map(|_| choose_terminal_input_fragment(g))
- .flatten()
+ .flat_map(|_| choose_terminal_input_fragment(g))
.collect(),
)
}
@@ -59,7 +58,7 @@ fn choose_terminal_input_fragment<G: quickcheck::Gen>(g: &mut G) -> Vec<u8> {
let c: Result<char, _> = std::convert::TryFrom::try_from(u);
let c = match c {
Ok(c) => c,
- Err(e) => panic!("failed to create char from {}: {}", u, e),
+ Err(e) => panic!("failed to create char from {u}: {e}"),
};
let mut b = [0; 4];
let s = c.encode_utf8(&mut b);
diff --git a/tests/split-escapes.rs b/tests/split-escapes.rs
index fa5b6b1..36fb647 100644
--- a/tests/split-escapes.rs
+++ b/tests/split-escapes.rs
@@ -7,7 +7,7 @@ fn get_file_contents(name: &str) -> Vec<u8> {
buf
}
-fn write_to_parser(chunks: &mut Vec<Vec<u8>>) -> (String, Vec<u8>) {
+fn write_to_parser(chunks: &mut [Vec<u8>]) -> (String, Vec<u8>) {
let mut parser = vt100::Parser::new(37, 193, 0);
for chunk in chunks.iter_mut() {
parser.process(chunk);
@@ -21,7 +21,7 @@ fn write_to_parser(chunks: &mut Vec<Vec<u8>>) -> (String, Vec<u8>) {
fn test_splits(filename: &str, limit: Option<usize>) {
let bytes = get_file_contents(filename);
let len = bytes.len();
- let expected = write_to_parser(&mut vec![bytes.clone()]);
+ let expected = write_to_parser(&mut [bytes.clone()]);
for i in 0..(len - 1) {
if let Some(limit) = limit {
if i > limit {
@@ -34,9 +34,7 @@ fn test_splits(filename: &str, limit: Option<usize>) {
let got = write_to_parser(&mut chunks);
assert!(
got == expected,
- "failed to render {} when split at byte {}",
- filename,
- i
+ "failed to render {filename} when split at byte {i}"
);
}
}
diff --git a/tests/window_contents.rs b/tests/window_contents.rs
index a300438..a3df341 100644
--- a/tests/window_contents.rs
+++ b/tests/window_contents.rs
@@ -556,7 +556,7 @@ fn diff_crawl(i: usize) {
let screens: Vec<_> = (1..=i)
.map(|i| {
let mut file =
- std::fs::File::open(format!("tests/data/crawl/crawl{}", i))
+ std::fs::File::open(format!("tests/data/crawl/crawl{i}"))
.unwrap();
let mut frame = vec![];
file.read_to_end(&mut frame).unwrap();