From 1ec1666d770e86db894f50eba30c0d53e20a1827 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sun, 8 Oct 2023 01:04:52 +0200 Subject: [PATCH] fix: tests, clippy lints --- codegen/src/gen_locales.rs | 19 +++++++++---------- codegen/src/util.rs | 8 ++++++-- src/util/mod.rs | 8 ++++++-- tests/youtube.rs | 13 +++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/codegen/src/gen_locales.rs b/codegen/src/gen_locales.rs index bb9e523..0f4ad48 100644 --- a/codegen/src/gen_locales.rs +++ b/codegen/src/gen_locales.rs @@ -228,16 +228,15 @@ pub enum Country { .to_owned(); for (code, native_name) in &languages { - let enum_name = code - .split('-') - .map(|c| { - format!( - "{}{}", - c[0..1].to_owned().to_uppercase(), - c[1..].to_owned().to_lowercase() - ) - }) - .collect::(); + let enum_name = code.split('-').fold(String::new(), |mut output, c| { + let _ = write!( + output, + "{}{}", + c[0..1].to_owned().to_uppercase(), + c[1..].to_owned().to_lowercase() + ); + output + }); let en_name = lang_names.get(code).expect(code); diff --git a/codegen/src/util.rs b/codegen/src/util.rs index 5254255..6f547d7 100644 --- a/codegen/src/util.rs +++ b/codegen/src/util.rs @@ -134,12 +134,16 @@ where if c.is_ascii_digit() { buf.push(c); } else if !buf.is_empty() { - buf.parse::().map_or((), |n| numbers.push(n)); + if let Ok(n) = buf.parse::() { + numbers.push(n); + } buf.clear(); } } if !buf.is_empty() { - buf.parse::().map_or((), |n| numbers.push(n)); + if let Ok(n) = buf.parse::() { + numbers.push(n); + } } numbers diff --git a/src/util/mod.rs b/src/util/mod.rs index 91c1ddc..a29a6d2 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -159,12 +159,16 @@ where if c.is_ascii_digit() { buf.push(c); } else if !buf.is_empty() { - buf.parse::().map_or((), |n| numbers.push(n)); + if let Ok(n) = buf.parse::() { + numbers.push(n); + } buf.clear(); } } if !buf.is_empty() { - buf.parse::().map_or((), |n| numbers.push(n)); + if let Ok(n) = buf.parse::() { + numbers.push(n); + } } numbers diff --git a/tests/youtube.rs b/tests/youtube.rs index 1054a61..4307278 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -326,13 +326,6 @@ fn get_player_error(#[case] id: &str, #[case] expect: UnavailabilityReason, rp: None, Some(("UCIekuFeMaV78xYfvpmoCnPg", "Best Music")), )] -#[case::short( - "RDCLAK5uy_kFQXdnqMaQCVx2wpUM4ZfbsGCDibZtkJk", - "Easy Pop", - false, - None, - None -)] #[case::nomusic( "PL1J-6JOckZtE_P9Xx8D3b2O6w0idhuKBe", "Minecraft SHINE", @@ -1127,10 +1120,10 @@ mod channel_rss { #[rstest] fn get_channel_rss_empty(rp: RustyPipe) { let channel = - tokio_test::block_on(rp.query().channel_rss("UC4fJNIVEOQ1fk15B_sqoOqg")).unwrap(); + tokio_test::block_on(rp.query().channel_rss("UCAyFbMjB3qAQSZBj6NCuBSg")).unwrap(); - assert_eq!(channel.id, "UC4fJNIVEOQ1fk15B_sqoOqg"); - assert_eq!(channel.name, "Bilal Saeed - Topic"); + assert_eq!(channel.id, "UCAyFbMjB3qAQSZBj6NCuBSg"); + assert_eq!(channel.name, "Cheryl Calogero"); assert!(channel.videos.is_empty()); }