#![allow(clippy::unwrap_used, reason = "allow in test files")]
use std::num::NonZeroU8;
use super::{ColorFamily, Resolution, SampleType, VideoFormat, VideoInfo};
#[test]
fn video_format_reports_plane_count_for_gray_and_yuv() {
let gray = VideoFormat {
color_family: ColorFamily::Gray,
sample_type: SampleType::Integer,
bits_per_sample: NonZeroU8::new(8).unwrap(),
bytes_per_sample: NonZeroU8::new(1).unwrap(),
sub_sampling_w: 0,
sub_sampling_h: 0,
};
let yuv = VideoFormat {
color_family: ColorFamily::Yuv,
sample_type: SampleType::Integer,
bits_per_sample: NonZeroU8::new(10).unwrap(),
bytes_per_sample: NonZeroU8::new(2).unwrap(),
sub_sampling_w: 1,
sub_sampling_h: 1,
};
assert_eq!(gray.plane_count(), 1);
assert_eq!(yuv.plane_count(), 3);
}
#[test]
fn video_info_keeps_constant_dimensions_and_frame_count() {
let format = VideoFormat {
color_family: ColorFamily::Yuv,
sample_type: SampleType::Integer,
bits_per_sample: NonZeroU8::new(8).unwrap(),
bytes_per_sample: NonZeroU8::new(1).unwrap(),
sub_sampling_w: 1,
sub_sampling_h: 1,
};
let info = VideoInfo {
format,
resolution: Resolution {
width: 672,
height: 2750,
},
num_frames: 10,
};
assert_eq!(info.resolution.width, 672);
assert_eq!(info.resolution.height, 2750);
assert_eq!(info.num_frames, 10);
}