mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-26 00:51:00 +00:00
Merge pull request #74 from GnomedDev/fix-warnings
Fix warnings added over the last 3 years
This commit is contained in:
commit
8432c003d1
17 changed files with 94 additions and 110 deletions
11
src/lib.rs
11
src/lib.rs
|
@ -1,12 +1,7 @@
|
||||||
#![doc(html_root_url = "https://docs.rs/hls_m3u8/0.4.1")]
|
#![doc(html_root_url = "https://docs.rs/hls_m3u8/0.4.1")]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![warn(
|
#![warn(clippy::cargo, clippy::inline_always)]
|
||||||
clippy::pedantic, //
|
|
||||||
clippy::nursery,
|
|
||||||
clippy::cargo,
|
|
||||||
clippy::inline_always,
|
|
||||||
)]
|
|
||||||
#![allow(
|
#![allow(
|
||||||
clippy::non_ascii_literal,
|
clippy::non_ascii_literal,
|
||||||
clippy::redundant_pub_crate,
|
clippy::redundant_pub_crate,
|
||||||
|
@ -19,10 +14,10 @@
|
||||||
clippy::clone_on_ref_ptr,
|
clippy::clone_on_ref_ptr,
|
||||||
clippy::decimal_literal_representation,
|
clippy::decimal_literal_representation,
|
||||||
clippy::get_unwrap,
|
clippy::get_unwrap,
|
||||||
clippy::expect_used,
|
|
||||||
clippy::unneeded_field_pattern,
|
clippy::unneeded_field_pattern,
|
||||||
clippy::wrong_pub_self_convention
|
clippy::wrong_self_convention
|
||||||
)]
|
)]
|
||||||
|
#![cfg_attr(not(test), warn(clippy::expect_used))]
|
||||||
// those should not be present in production code:
|
// those should not be present in production code:
|
||||||
#![deny(
|
#![deny(
|
||||||
clippy::print_stdout,
|
clippy::print_stdout,
|
||||||
|
|
|
@ -68,7 +68,7 @@ use crate::{Error, RequiredVersion};
|
||||||
/// closed_captions: None,
|
/// closed_captions: None,
|
||||||
/// stream_data: StreamData::builder()
|
/// stream_data: StreamData::builder()
|
||||||
/// .bandwidth(150000)
|
/// .bandwidth(150000)
|
||||||
/// .codecs(&["avc1.42e00a", "mp4a.40.2"])
|
/// .codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
/// .resolution((416, 234))
|
/// .resolution((416, 234))
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap(),
|
/// .unwrap(),
|
||||||
|
@ -81,7 +81,7 @@ use crate::{Error, RequiredVersion};
|
||||||
/// closed_captions: None,
|
/// closed_captions: None,
|
||||||
/// stream_data: StreamData::builder()
|
/// stream_data: StreamData::builder()
|
||||||
/// .bandwidth(240000)
|
/// .bandwidth(240000)
|
||||||
/// .codecs(&["avc1.42e00a", "mp4a.40.2"])
|
/// .codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
/// .resolution((416, 234))
|
/// .resolution((416, 234))
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap(),
|
/// .unwrap(),
|
||||||
|
@ -190,7 +190,7 @@ impl<'a> MasterPlaylist<'a> {
|
||||||
/// closed_captions: None,
|
/// closed_captions: None,
|
||||||
/// stream_data: StreamData::builder()
|
/// stream_data: StreamData::builder()
|
||||||
/// .bandwidth(150000)
|
/// .bandwidth(150000)
|
||||||
/// .codecs(&["avc1.42e00a", "mp4a.40.2"])
|
/// .codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
/// .resolution((416, 234))
|
/// .resolution((416, 234))
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap(),
|
/// .unwrap(),
|
||||||
|
@ -203,7 +203,7 @@ impl<'a> MasterPlaylist<'a> {
|
||||||
/// closed_captions: None,
|
/// closed_captions: None,
|
||||||
/// stream_data: StreamData::builder()
|
/// stream_data: StreamData::builder()
|
||||||
/// .bandwidth(240000)
|
/// .bandwidth(240000)
|
||||||
/// .codecs(&["avc1.42e00a", "mp4a.40.2"])
|
/// .codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
/// .resolution((416, 234))
|
/// .resolution((416, 234))
|
||||||
/// .build()
|
/// .build()
|
||||||
/// .unwrap(),
|
/// .unwrap(),
|
||||||
|
@ -262,7 +262,7 @@ impl<'a> MasterPlaylist<'a> {
|
||||||
pub fn associated_with<'b>(
|
pub fn associated_with<'b>(
|
||||||
&'b self,
|
&'b self,
|
||||||
stream: &'b VariantStream<'_>,
|
stream: &'b VariantStream<'_>,
|
||||||
) -> impl Iterator<Item = &ExtXMedia<'a>> + 'b {
|
) -> impl Iterator<Item = &'b ExtXMedia<'a>> + 'b {
|
||||||
self.media
|
self.media
|
||||||
.iter()
|
.iter()
|
||||||
.filter(move |media| stream.is_associated(media))
|
.filter(move |media| stream.is_associated(media))
|
||||||
|
@ -576,7 +576,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(150_000)
|
.bandwidth(150_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -589,7 +589,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(240_000)
|
.bandwidth(240_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -662,7 +662,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(150_000)
|
.bandwidth(150_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -675,7 +675,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(240_000)
|
.bandwidth(240_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -688,7 +688,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(440_000)
|
.bandwidth(440_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -701,7 +701,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(640_000)
|
.bandwidth(640_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((640, 360))
|
.resolution((640, 360))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -714,7 +714,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(64000)
|
.bandwidth(64000)
|
||||||
.codecs(&["mp4a.40.5"])
|
.codecs(["mp4a.40.5"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -737,7 +737,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(150_000)
|
.bandwidth(150_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -750,7 +750,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(240_000)
|
.bandwidth(240_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -763,7 +763,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(440_000)
|
.bandwidth(440_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((416, 234))
|
.resolution((416, 234))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -776,7 +776,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(640_000)
|
.bandwidth(640_000)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.resolution((640, 360))
|
.resolution((640, 360))
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -789,7 +789,7 @@ mod tests {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(64000)
|
.bandwidth(64000)
|
||||||
.codecs(&["mp4a.40.5"])
|
.codecs(["mp4a.40.5"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
|
|
@ -367,7 +367,7 @@ impl<'a> MediaPlaylistBuilder<'a> {
|
||||||
allowable_excess_duration: self
|
allowable_excess_duration: self
|
||||||
.allowable_excess_duration
|
.allowable_excess_duration
|
||||||
.unwrap_or_else(|| Duration::from_secs(0)),
|
.unwrap_or_else(|| Duration::from_secs(0)),
|
||||||
unknown: self.unknown.clone().unwrap_or_else(Vec::new),
|
unknown: self.unknown.clone().unwrap_or_default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::{Error, RequiredVersion};
|
||||||
///
|
///
|
||||||
/// [`MediaPlaylist`]: crate::MediaPlaylist
|
/// [`MediaPlaylist`]: crate::MediaPlaylist
|
||||||
/// [`MasterPlaylist`]: crate::MasterPlaylist
|
/// [`MasterPlaylist`]: crate::MasterPlaylist
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)]
|
||||||
pub struct ExtXVersion(ProtocolVersion);
|
pub struct ExtXVersion(ProtocolVersion);
|
||||||
|
|
||||||
impl ExtXVersion {
|
impl ExtXVersion {
|
||||||
|
@ -59,10 +59,6 @@ impl fmt::Display for ExtXVersion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ExtXVersion {
|
|
||||||
fn default() -> Self { Self(ProtocolVersion::default()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<ProtocolVersion> for ExtXVersion {
|
impl From<ProtocolVersion> for ExtXVersion {
|
||||||
fn from(value: ProtocolVersion) -> Self { Self(value) }
|
fn from(value: ProtocolVersion) -> Self { Self(value) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,8 +138,8 @@ pub struct ExtXMedia<'a> {
|
||||||
/// following characteristics:
|
/// following characteristics:
|
||||||
/// - `"public.accessibility.transcribes-spoken-dialog"`,
|
/// - `"public.accessibility.transcribes-spoken-dialog"`,
|
||||||
/// - `"public.accessibility.describes-music-and-sound"`, and
|
/// - `"public.accessibility.describes-music-and-sound"`, and
|
||||||
/// - `"public.easy-to-read"` (which indicates that the subtitles have
|
/// - `"public.easy-to-read"` (which indicates that the subtitles have been
|
||||||
/// been edited for ease of reading).
|
/// edited for ease of reading).
|
||||||
///
|
///
|
||||||
/// An `ExtXMedia` instance with [`MediaType::Audio`] may include the
|
/// An `ExtXMedia` instance with [`MediaType::Audio`] may include the
|
||||||
/// following characteristic:
|
/// following characteristic:
|
||||||
|
@ -745,28 +745,18 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parser_error() {
|
fn test_parser_error() {
|
||||||
assert_eq!(ExtXMedia::try_from("").is_err(), true);
|
assert!(ExtXMedia::try_from("").is_err());
|
||||||
assert_eq!(ExtXMedia::try_from("garbage").is_err(), true);
|
assert!(ExtXMedia::try_from("garbage").is_err());
|
||||||
|
|
||||||
assert_eq!(
|
assert!(ExtXMedia::try_from(
|
||||||
ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,URI=\"http://www.example.com\"")
|
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,URI=\"http://www.example.com\""
|
||||||
.is_err(),
|
)
|
||||||
true
|
.is_err());
|
||||||
);
|
assert!(ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,INSTREAM-ID=CC1").is_err());
|
||||||
assert_eq!(
|
|
||||||
ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,INSTREAM-ID=CC1").is_err(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
assert!(ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,DEFAULT=YES,AUTOSELECT=NO").is_err());
|
||||||
ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,DEFAULT=YES,AUTOSELECT=NO").is_err(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
assert!(ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,FORCED=YES").is_err());
|
||||||
ExtXMedia::try_from("#EXT-X-MEDIA:TYPE=AUDIO,FORCED=YES").is_err(),
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl<'a> RequiredVersion for ExtXSessionKey<'a> {
|
||||||
|
|
||||||
impl<'a> fmt::Display for ExtXSessionKey<'a> {
|
impl<'a> fmt::Display for ExtXSessionKey<'a> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}{}", Self::PREFIX, self.0.to_string())
|
write!(f, "{}{}", Self::PREFIX, self.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -137,6 +137,7 @@ impl RequiredVersion for ExtXByteRange {
|
||||||
fn required_version(&self) -> ProtocolVersion { ProtocolVersion::V4 }
|
fn required_version(&self) -> ProtocolVersion { ProtocolVersion::V4 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::from_over_into)] // Some magic `From` blanket impl is going on that means this can't be done.
|
||||||
impl Into<ByteRange> for ExtXByteRange {
|
impl Into<ByteRange> for ExtXByteRange {
|
||||||
fn into(self) -> ByteRange { self.0 }
|
fn into(self) -> ByteRange { self.0 }
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,7 +502,7 @@ impl<'a> fmt::Display for ExtXDateRange<'a> {
|
||||||
|
|
||||||
#[cfg(not(feature = "chrono"))]
|
#[cfg(not(feature = "chrono"))]
|
||||||
{
|
{
|
||||||
write!(f, ",START-DATE={}", quote(&value))?;
|
write!(f, ",START-DATE={}", quote(value))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ impl<'a> fmt::Display for ExtXDateRange<'a> {
|
||||||
|
|
||||||
#[cfg(not(feature = "chrono"))]
|
#[cfg(not(feature = "chrono"))]
|
||||||
{
|
{
|
||||||
write!(f, ",END-DATE={}", quote(&value))?;
|
write!(f, ",END-DATE={}", quote(value))?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ impl<'a> TryFrom<&'a str> for ExtInf<'a> {
|
||||||
.next()
|
.next()
|
||||||
.map(str::trim)
|
.map(str::trim)
|
||||||
.filter(|value| !value.is_empty())
|
.filter(|value| !value.is_empty())
|
||||||
.map(|v| Cow::Borrowed(v));
|
.map(Cow::Borrowed);
|
||||||
|
|
||||||
Ok(Self { duration, title })
|
Ok(Self { duration, title })
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ impl ByteRange {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use hls_m3u8::types::ByteRange;
|
/// # use hls_m3u8::types::ByteRange;
|
||||||
/// let range = ByteRange::from(5..usize::max_value());
|
/// let range = ByteRange::from(5..usize::MAX);
|
||||||
///
|
///
|
||||||
/// // this would cause the end to overflow
|
/// // this would cause the end to overflow
|
||||||
/// let nrange = range.saturating_add(1);
|
/// let nrange = range.saturating_add(1);
|
||||||
|
@ -145,10 +145,10 @@ impl ByteRange {
|
||||||
} else {
|
} else {
|
||||||
// it is ensured at construction that the start will never be larger than the
|
// it is ensured at construction that the start will never be larger than the
|
||||||
// end. This clause can therefore be only reached if the end overflowed.
|
// end. This clause can therefore be only reached if the end overflowed.
|
||||||
// -> It is only possible to add `usize::max_value() - end` to the start.
|
// -> It is only possible to add `usize::MAX - end` to the start.
|
||||||
if let Some(start) = start.checked_add(usize::max_value() - self.end) {
|
if let Some(start) = start.checked_add(usize::MAX - self.end) {
|
||||||
self.start = Some(start);
|
self.start = Some(start);
|
||||||
self.end = usize::max_value();
|
self.end = usize::MAX;
|
||||||
} else {
|
} else {
|
||||||
// both end + start overflowed -> do not change anything
|
// both end + start overflowed -> do not change anything
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,6 @@ macro_rules! impl_from_ranges {
|
||||||
// stable (`Into<i64> for usize` is reserved for upstream crates ._.)
|
// stable (`Into<i64> for usize` is reserved for upstream crates ._.)
|
||||||
impl_from_ranges![u64, u32, u16, u8, usize, i32];
|
impl_from_ranges![u64, u32, u16, u8, usize, i32];
|
||||||
|
|
||||||
#[must_use]
|
|
||||||
impl RangeBounds<usize> for ByteRange {
|
impl RangeBounds<usize> for ByteRange {
|
||||||
fn start_bound(&self) -> Bound<&usize> {
|
fn start_bound(&self) -> Bound<&usize> {
|
||||||
self.start
|
self.start
|
||||||
|
@ -488,7 +487,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "attempt to add with overflow"]
|
#[should_panic = "attempt to add with overflow"]
|
||||||
fn test_add_assign_panic() {
|
fn test_add_assign_panic() {
|
||||||
let mut range = ByteRange::from(4..usize::max_value());
|
let mut range = ByteRange::from(4..usize::MAX);
|
||||||
range += 5;
|
range += 5;
|
||||||
|
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
@ -529,7 +528,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "attempt to add with overflow"]
|
#[should_panic = "attempt to add with overflow"]
|
||||||
fn test_add_panic() { let _ = ByteRange::from(usize::max_value()..usize::max_value()) + 1; }
|
fn test_add_panic() { let _ = ByteRange::from(usize::MAX..usize::MAX) + 1; }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[allow(clippy::identity_op)]
|
#[allow(clippy::identity_op)]
|
||||||
|
@ -580,28 +579,28 @@ mod tests {
|
||||||
|
|
||||||
// overflow
|
// overflow
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ByteRange::from(usize::max_value()..usize::max_value()).saturating_add(1),
|
ByteRange::from(usize::MAX..usize::MAX).saturating_add(1),
|
||||||
ByteRange::from(usize::max_value()..usize::max_value())
|
ByteRange::from(usize::MAX..usize::MAX)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ByteRange::from(..usize::max_value()).saturating_add(1),
|
ByteRange::from(..usize::MAX).saturating_add(1),
|
||||||
ByteRange::from(..usize::max_value())
|
ByteRange::from(..usize::MAX)
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ByteRange::from(usize::max_value() - 5..usize::max_value()).saturating_add(1),
|
ByteRange::from(usize::MAX - 5..usize::MAX).saturating_add(1),
|
||||||
ByteRange::from(usize::max_value() - 5..usize::max_value())
|
ByteRange::from(usize::MAX - 5..usize::MAX)
|
||||||
);
|
);
|
||||||
|
|
||||||
// overflow, but something can be added to the range:
|
// overflow, but something can be added to the range:
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ByteRange::from(usize::max_value() - 5..usize::max_value() - 3).saturating_add(4),
|
ByteRange::from(usize::MAX - 5..usize::MAX - 3).saturating_add(4),
|
||||||
ByteRange::from(usize::max_value() - 2..usize::max_value())
|
ByteRange::from(usize::MAX - 2..usize::MAX)
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
ByteRange::from(..usize::max_value() - 3).saturating_add(4),
|
ByteRange::from(..usize::MAX - 3).saturating_add(4),
|
||||||
ByteRange::from(..usize::max_value())
|
ByteRange::from(..usize::MAX)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::unit_cmp)] // fucked test
|
||||||
fn test_hash() {
|
fn test_hash() {
|
||||||
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
||||||
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
||||||
|
@ -251,8 +252,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_partial_eq() {
|
fn test_partial_eq() {
|
||||||
assert_eq!(Float::new(1.0).eq(&Float::new(1.0)), true);
|
assert_eq!(Float::new(1.0), Float::new(1.0));
|
||||||
assert_eq!(Float::new(1.0).eq(&Float::new(33.3)), false);
|
assert_ne!(Float::new(1.0), Float::new(33.3));
|
||||||
assert_eq!(Float::new(1.1), 1.1);
|
assert_eq!(Float::new(1.1), 1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,15 +277,15 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must be finite: `inf`"]
|
#[should_panic = "float must be finite: `inf`"]
|
||||||
fn test_new_infinite() { let _ = Float::new(::core::f32::INFINITY); }
|
fn test_new_infinite() { let _ = Float::new(f32::INFINITY); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must be finite: `-inf`"]
|
#[should_panic = "float must be finite: `-inf`"]
|
||||||
fn test_new_neg_infinite() { let _ = Float::new(::core::f32::NEG_INFINITY); }
|
fn test_new_neg_infinite() { let _ = Float::new(f32::NEG_INFINITY); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must not be `NaN`"]
|
#[should_panic = "float must not be `NaN`"]
|
||||||
fn test_new_nan() { let _ = Float::new(::core::f32::NAN); }
|
fn test_new_nan() { let _ = Float::new(f32::NAN); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_as_f32() {
|
fn test_as_f32() {
|
||||||
|
@ -304,8 +305,8 @@ mod tests {
|
||||||
assert_eq!(Float::try_from(1.1_f32).unwrap(), Float::new(1.1));
|
assert_eq!(Float::try_from(1.1_f32).unwrap(), Float::new(1.1));
|
||||||
assert_eq!(Float::try_from(-1.1_f32).unwrap(), Float::new(-1.1));
|
assert_eq!(Float::try_from(-1.1_f32).unwrap(), Float::new(-1.1));
|
||||||
|
|
||||||
assert!(Float::try_from(::core::f32::INFINITY).is_err());
|
assert!(Float::try_from(f32::INFINITY).is_err());
|
||||||
assert!(Float::try_from(::core::f32::NAN).is_err());
|
assert!(Float::try_from(f32::NAN).is_err());
|
||||||
assert!(Float::try_from(::core::f32::NEG_INFINITY).is_err());
|
assert!(Float::try_from(f32::NEG_INFINITY).is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl FromStr for KeyFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for KeyFormat {
|
impl fmt::Display for KeyFormat {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", quote(&"identity")) }
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", quote("identity")) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This tag requires [`ProtocolVersion::V5`].
|
/// This tag requires [`ProtocolVersion::V5`].
|
||||||
|
|
|
@ -459,6 +459,7 @@ mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::unit_cmp)] // fucked test
|
||||||
fn test_hash() {
|
fn test_hash() {
|
||||||
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
||||||
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
||||||
|
@ -665,13 +666,13 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_is_default() {
|
fn test_is_default() {
|
||||||
assert_eq!(KeyFormatVersions::new().is_default(), true);
|
assert!(KeyFormatVersions::new().is_default());
|
||||||
assert_eq!(KeyFormatVersions::default().is_default(), true);
|
assert!(KeyFormatVersions::default().is_default());
|
||||||
|
|
||||||
assert_eq!(KeyFormatVersions::from([]).is_default(), true);
|
assert!(KeyFormatVersions::from([]).is_default());
|
||||||
assert_eq!(KeyFormatVersions::from([1]).is_default(), true);
|
assert!(KeyFormatVersions::from([1]).is_default());
|
||||||
|
|
||||||
assert_eq!(KeyFormatVersions::from([1, 2, 3]).is_default(), false);
|
assert!(!KeyFormatVersions::from([1, 2, 3]).is_default());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -56,8 +56,8 @@ impl From<(usize, usize)> for Resolution {
|
||||||
fn from(value: (usize, usize)) -> Self { Self::new(value.0, value.1) }
|
fn from(value: (usize, usize)) -> Self { Self::new(value.0, value.1) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<(usize, usize)> for Resolution {
|
impl From<Resolution> for (usize, usize) {
|
||||||
fn into(self) -> (usize, usize) { (self.width, self.height) }
|
fn from(val: Resolution) -> Self { (val.width, val.height) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Resolution {
|
impl FromStr for Resolution {
|
||||||
|
|
|
@ -224,6 +224,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[allow(clippy::unit_cmp)] // fucked test
|
||||||
fn test_hash() {
|
fn test_hash() {
|
||||||
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_left = std::collections::hash_map::DefaultHasher::new();
|
||||||
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
let mut hasher_right = std::collections::hash_map::DefaultHasher::new();
|
||||||
|
@ -261,8 +262,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_partial_eq() {
|
fn test_partial_eq() {
|
||||||
assert_eq!(UFloat::new(1.0).eq(&UFloat::new(1.0)), true);
|
assert_eq!(UFloat::new(1.0), UFloat::new(1.0));
|
||||||
assert_eq!(UFloat::new(1.0).eq(&UFloat::new(33.3)), false);
|
assert_ne!(UFloat::new(1.0), UFloat::new(33.3));
|
||||||
assert_eq!(UFloat::new(1.1), 1.1);
|
assert_eq!(UFloat::new(1.1), 1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,15 +277,15 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must be finite: `inf`"]
|
#[should_panic = "float must be finite: `inf`"]
|
||||||
fn test_new_infinite() { let _ = UFloat::new(::core::f32::INFINITY); }
|
fn test_new_infinite() { let _ = UFloat::new(f32::INFINITY); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must be finite: `-inf`"]
|
#[should_panic = "float must be finite: `-inf`"]
|
||||||
fn test_new_neg_infinite() { let _ = UFloat::new(::core::f32::NEG_INFINITY); }
|
fn test_new_neg_infinite() { let _ = UFloat::new(f32::NEG_INFINITY); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic = "float must not be `NaN`"]
|
#[should_panic = "float must not be `NaN`"]
|
||||||
fn test_new_nan() { let _ = UFloat::new(::core::f32::NAN); }
|
fn test_new_nan() { let _ = UFloat::new(f32::NAN); }
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_as_f32() {
|
fn test_as_f32() {
|
||||||
|
@ -305,9 +306,9 @@ mod tests {
|
||||||
UFloat::try_from(-1.1_f32),
|
UFloat::try_from(-1.1_f32),
|
||||||
Err(Error::custom("float must be positive: `-1.1`"))
|
Err(Error::custom("float must be positive: `-1.1`"))
|
||||||
);
|
);
|
||||||
assert!(UFloat::try_from(::core::f32::INFINITY).is_err());
|
assert!(UFloat::try_from(f32::INFINITY).is_err());
|
||||||
assert!(UFloat::try_from(::core::f32::NAN).is_err());
|
assert!(UFloat::try_from(f32::NAN).is_err());
|
||||||
assert!(UFloat::try_from(::core::f32::NEG_INFINITY).is_err());
|
assert!(UFloat::try_from(f32::NEG_INFINITY).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -63,7 +63,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(195023)
|
.bandwidth(195023)
|
||||||
.codecs(&["avc1.42e00a", "mp4a.40.2"])
|
.codecs(["avc1.42e00a", "mp4a.40.2"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -75,7 +75,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(591680)
|
.bandwidth(591680)
|
||||||
.codecs(&["avc1.42e01e", "mp4a.40.2"])
|
.codecs(["avc1.42e01e", "mp4a.40.2"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(65000)
|
.bandwidth(65000)
|
||||||
.codecs(&["mp4a.40.5"])
|
.codecs(["mp4a.40.5"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -279,7 +279,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(65000)
|
.bandwidth(65000)
|
||||||
.codecs(&["mp4a.40.5"])
|
.codecs(["mp4a.40.5"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -344,7 +344,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(1280000)
|
.bandwidth(1280000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -356,7 +356,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(2560000)
|
.bandwidth(2560000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -368,7 +368,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(7680000)
|
.bandwidth(7680000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -380,7 +380,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(65000)
|
.bandwidth(65000)
|
||||||
.codecs(&["mp4a.40.5"])
|
.codecs(["mp4a.40.5"])
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
|
@ -517,7 +517,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(1280000)
|
.bandwidth(1280000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.video("low")
|
.video("low")
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -530,7 +530,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(2560000)
|
.bandwidth(2560000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.video("mid")
|
.video("mid")
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -543,7 +543,7 @@ generate_tests! {
|
||||||
closed_captions: None,
|
closed_captions: None,
|
||||||
stream_data: StreamData::builder()
|
stream_data: StreamData::builder()
|
||||||
.bandwidth(7680000)
|
.bandwidth(7680000)
|
||||||
.codecs(&["..."])
|
.codecs(["..."])
|
||||||
.video("hi")
|
.video("hi")
|
||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
Loading…
Reference in a new issue