ID3v2: Add test for #204

A UFID frame without an owner is invalid, and will fail in `ParsingMode::Strict`. In `ParsingMode::BestAttempt`, however, we will just replace it with an empty string.
This commit is contained in:
Serial 2023-06-03 12:38:45 -04:00 committed by Alex
parent ed68ca8851
commit e54a6135f9

View file

@ -68,3 +68,24 @@ impl Hash for UniqueFileIdentifierFrame {
self.owner.hash(state);
}
}
#[cfg(test)]
mod tests {
#[test]
fn issue_204_invalid_ufid_parsing_mode_best_attempt() {
use crate::id3::v2::UniqueFileIdentifierFrame;
use crate::ParsingMode;
let ufid_no_owner = UniqueFileIdentifierFrame {
owner: String::new(),
identifier: vec![0],
};
let bytes = ufid_no_owner.as_bytes();
assert!(UniqueFileIdentifierFrame::parse(&mut &bytes[..], ParsingMode::Strict).is_err());
assert!(
UniqueFileIdentifierFrame::parse(&mut &bytes[..], ParsingMode::BestAttempt).is_ok()
);
}
}