2021-06-30 05:00:40 +00:00
|
|
|
#![cfg(feature = "default")]
|
|
|
|
|
2021-06-30 03:38:20 +00:00
|
|
|
use lofty::{Id3Format, OggFormat, Tag, TagType};
|
2021-06-29 18:51:49 +00:00
|
|
|
|
|
|
|
macro_rules! convert_tag {
|
|
|
|
($tag: ident) => {
|
|
|
|
assert_eq!($tag.title(), Some("Title Updated"));
|
|
|
|
assert_eq!($tag.artist_str(), Some("Artist Updated"));
|
2021-07-06 03:15:45 +00:00
|
|
|
assert_eq!($tag.track_number(), Some(5));
|
2021-06-29 18:51:49 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_conversions() {
|
|
|
|
let mut tag = Tag::new().read_from_path("tests/assets/a.mp3").unwrap();
|
|
|
|
|
|
|
|
tag.set_title("Title Updated");
|
|
|
|
tag.set_artist("Artist Updated");
|
2021-07-06 03:15:45 +00:00
|
|
|
tag.set_track_number(5);
|
2021-06-29 18:51:49 +00:00
|
|
|
convert_tag!(tag);
|
|
|
|
|
|
|
|
let tag = tag.to_dyn_tag(TagType::Ape);
|
|
|
|
convert_tag!(tag);
|
|
|
|
|
|
|
|
let tag = tag.to_dyn_tag(TagType::Mp4);
|
|
|
|
convert_tag!(tag);
|
|
|
|
|
|
|
|
let tag = tag.to_dyn_tag(TagType::RiffInfo);
|
|
|
|
convert_tag!(tag);
|
|
|
|
|
|
|
|
let tag = tag.to_dyn_tag(TagType::Ogg(OggFormat::Vorbis));
|
|
|
|
convert_tag!(tag);
|
|
|
|
|
|
|
|
let tag = tag.to_dyn_tag(TagType::Id3v2(Id3Format::Form));
|
|
|
|
convert_tag!(tag);
|
|
|
|
}
|