clippy fixes

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2022-10-11 09:47:13 +02:00
parent 2ae95b5f4e
commit 28e30719e8
4 changed files with 13 additions and 18 deletions

View File

@ -207,8 +207,8 @@ mod test {
fn test1() {
let mut buffer = ByteBuffer::new();
let slice = buffer.get_free_mut_slice();
for i in 0..slice.len() {
slice[i] = (i % 255) as u8;
for (i, value) in slice.iter_mut().enumerate() {
*value = (i % 255) as u8;
}
buffer.add_size(5);

View File

@ -161,19 +161,16 @@ mod test {
fn test_sparse_copy() {
// test sparse
let mut test_data = Vec::new();
for _ in 0..LEN / 2 {
test_data.push(1u8);
}
for _ in 0..LEN / 2 {
test_data.push(0u8);
}
test_data.resize(LEN / 2, 1u8);
test_data.resize(LEN, 0u8);
let mut test_data = Cursor::new(test_data);
let mut result_data = Cursor::new(vec![0; LEN]);
let result =
sparse_copy(&mut test_data, &mut result_data).expect("error during sparse copy");
assert_eq!(result.written, LEN as u64);
assert_eq!(result.seeked_last, true);
assert!(result.seeked_last);
for i in 0..LEN {
if i < LEN / 2 {
assert_eq!(result_data.get_ref()[i], 1);
@ -189,7 +186,7 @@ mod test {
let result =
sparse_copy(&mut test_data, &mut result_data).expect("error during sparse copy");
assert_eq!(result.written, LEN as u64);
assert_eq!(result.seeked_last, false);
assert!(!result.seeked_last);
for i in 0..LEN {
assert_eq!(result_data.get_ref()[i], 1);
}
@ -214,12 +211,8 @@ mod test {
let mut fut = async {
// test sparse
let mut test_data = Vec::new();
for _ in 0..LEN / 2 {
test_data.push(1u8);
}
for _ in 0..LEN / 2 {
test_data.push(0u8);
}
test_data.resize(LEN / 2, 1u8);
test_data.resize(LEN, 0u8);
let mut test_data = Cursor::new(test_data);
let mut result_data = Cursor::new(vec![0; LEN]);
@ -228,7 +221,7 @@ mod test {
.expect("error during sparse copy");
assert_eq!(result.written, LEN as u64);
assert_eq!(result.seeked_last, true);
assert!(result.seeked_last);
for i in 0..LEN {
if i < LEN / 2 {
assert_eq!(result_data.get_ref()[i], 1);
@ -246,7 +239,7 @@ mod test {
.expect("error during sparse copy");
assert_eq!(result.written, LEN as u64);
assert_eq!(result.seeked_last, false);
assert!(!result.seeked_last);
for i in 0..LEN {
assert_eq!(result_data.get_ref()[i], 1);
}

View File

@ -234,6 +234,7 @@ where
}
#[test]
#[allow(clippy::blacklisted_name)]
fn test_extraction() {
use serde::Deserialize;

View File

@ -16,6 +16,7 @@ const fn make_test_time(mday: i32, hour: i32, min: i32) -> i64 {
}
#[test]
#[allow(clippy::identity_op)]
fn test_compute_next_event() -> Result<(), Error> {
let test_value = |v: &'static str, last: i64, expect: i64| -> Result<i64, Error> {
let event: CalendarEvent = match format!("{} UTC", v).parse() {