pub mod anim;
pub mod fourcc;
pub mod reader;
pub mod scan;
pub mod vp8x;
pub mod writer;
pub(crate) fn read_u24_le(a: u8, b: u8, c: u8) -> u32 {
u32::from(a) | (u32::from(b) << 8) | (u32::from(c) << 16)
}
pub(crate) const fn write_u24_le(value: u32) -> [u8; 3] {
let [a, b, c, _] = value.to_le_bytes();
[a, b, c]
}
#[cfg(test)]
mod tests {
use proptest::prelude::*;
use super::{read_u24_le, write_u24_le};
proptest! {
#[test]
fn u24_round_trips_full_domain(value in 0u32..(1 << 24)) {
let [a, b, c] = write_u24_le(value);
prop_assert_eq!(read_u24_le(a, b, c), value);
}
}
#[test]
fn u24_round_trips_across_the_range() {
for value in [0u32, 1, 255, 256, 0x00_12_34, 0xFF_FF_FF, (1 << 24) - 1] {
let [a, b, c] = write_u24_le(value);
assert_eq!(read_u24_le(a, b, c), value);
}
}
#[test]
fn write_u24_le_is_little_endian_and_drops_the_high_byte() {
assert_eq!(write_u24_le(0x00_AB_CD_EF), [0xEF, 0xCD, 0xAB]);
}
}