lofty-rs/tests/conversions.rs
Serial 10ca5c0295 Create AudioTagEdit methods with macros, remove useless methods, rename unclear methods
Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
2021-07-09 11:45:37 -04:00

36 lines
857 B
Rust

#![cfg(feature = "default")]
use lofty::{Id3Format, OggFormat, Tag, TagType};
macro_rules! convert_tag {
($tag: ident) => {
assert_eq!($tag.title(), Some("Title Updated"));
assert_eq!($tag.artist(), Some("Artist Updated"));
assert_eq!($tag.track_number(), Some(5));
};
}
#[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");
tag.set_track_number(5);
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);
}