Skip to content

Commit

Permalink
feat: clippy the tests and make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
theJasonFan committed Feb 21, 2024
1 parent dfa3e1c commit 66ab8c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ jobs:
command: clippy
args: -- -D warnings

- name: Run cargo clippy on tests
uses: actions-rs/cargo@v1
with:
command: clippy
args: --tests -- -D warnings

test:
name: Test Suite
runs-on: ${{ matrix.os }}
Expand Down
6 changes: 3 additions & 3 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ mod tests {
let io = Io::default();
io.write_lines(&f1, &lines).unwrap();
let strings: Vec<String> = lines.iter().map(|l| l.to_string()).collect();
io.write_lines(&f2, &strings).unwrap();
io.write_lines(&f2, strings).unwrap();

let r1 = io.read_lines(&f1).unwrap();
let r2 = io.read_lines(&f2).unwrap();
Expand All @@ -382,8 +382,8 @@ mod tests {
let gzipped = tempdir.path().join("gzipped.txt.gz");

let io = Io::default();
io.write_lines(&text, &mut lines.iter()).unwrap();
io.write_lines(&gzipped, &mut lines.iter()).unwrap();
io.write_lines(&text, lines.iter()).unwrap();
io.write_lines(&gzipped, lines.iter()).unwrap();

let r1 = io.read_lines(&text).unwrap();
let r2 = io.read_lines(&gzipped).unwrap();
Expand Down
8 changes: 4 additions & 4 deletions src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ mod tests {
#[case] chunk_size: usize,
#[case] buffer_size: usize,
) {
let test_vec: Vec<usize> = (0..1_000_000).into_iter().collect();
let test_vec: Vec<usize> = (0..1_000_000).collect();
let test_vec2 = test_vec.clone();

let mut regular_iter = test_vec.into_iter();
Expand All @@ -249,7 +249,7 @@ mod tests {

#[test]
fn test_low_bound_on_channel_for_blocking() {
let chunked_iter = (0..100_000).into_iter().read_ahead(8, 1);
let chunked_iter = (0..100_000).read_ahead(8, 1);
for i in chunked_iter {
// Do some work so iter will get consumed
let _ = i % 2;
Expand Down Expand Up @@ -375,7 +375,7 @@ mod tests {
#[test]
#[should_panic(expected = "expected error message")]
fn test_panic_occurring_mid_chunk_returns_results_until_panic() {
let mut test_iter = FailingIter::new().into_iter().read_ahead(8, 1);
let mut test_iter = FailingIter::new().read_ahead(8, 1);

for _ in 0..FAIL_POINT {
panic::catch_unwind(AssertUnwindSafe(|| {
Expand Down Expand Up @@ -419,7 +419,7 @@ mod tests {
#[should_panic(expected = "expected error message")]
fn test_panic_occurring_after_iteration_raises() {
{
let mut test_iter = ExitFailingIter::new().into_iter().read_ahead(8, 1);
let mut test_iter = ExitFailingIter::new().read_ahead(8, 1);

for _ in 0..FAIL_POINT {
panic::catch_unwind(AssertUnwindSafe(|| {
Expand Down

0 comments on commit 66ab8c1

Please sign in to comment.