use super::*;
#[test]
fn a_family_demuxer_walks_every_word_it_handles() {
let format = ContainerFormat::new(SmolStr::new("mov,mp4,m4a,3gp,3g2,mj2"), None);
assert_eq!(format.name(), "mov,mp4,m4a,3gp,3g2,mj2");
assert_eq!(
format.names().collect::<Vec<_>>(),
["mov", "mp4", "m4a", "3gp", "3g2", "mj2"],
);
}
#[test]
fn a_single_format_demuxer_walks_one_word() {
let format = ContainerFormat::new(SmolStr::new("flac"), Some(SmolStr::new("raw FLAC")));
assert_eq!(format.names().collect::<Vec<_>>(), ["flac"]);
assert_eq!(format.long_name(), Some("raw FLAC"));
}
#[test]
fn a_format_without_a_description_is_still_a_format() {
let format = ContainerFormat::new(SmolStr::new("matroska,webm"), None);
assert_eq!(format.long_name(), None);
assert_eq!(format.names().collect::<Vec<_>>(), ["matroska", "webm"]);
}
#[test]
fn empty_words_are_not_names() {
let format = ContainerFormat::new(SmolStr::new("mp4,,mov,"), None);
assert_eq!(format.names().collect::<Vec<_>>(), ["mp4", "mov"]);
}
#[test]
fn the_words_are_what_a_typed_vocabulary_parses() {
let format = ContainerFormat::new(SmolStr::new("mov,mp4,m4a,3gp,3g2,mj2"), None);
let recognised: Vec<_> = format
.names()
.filter(|word| matches!(*word, "mov" | "mp4" | "mkv" | "webm"))
.collect();
assert_eq!(
recognised,
["mov", "mp4"],
"a family demuxer can offer several words a vocabulary knows, and choosing between them \
is the consumer's call rather than this crate's",
);
}
#[test]
fn a_null_context_has_no_format() {
assert_eq!(
unsafe { ContainerFormat::from_context(std::ptr::null()) },
None,
);
}