2021-04-03 00:47:44 +00:00
|
|
|
use lofty::*;
|
2020-10-27 15:00:22 +00:00
|
|
|
|
|
|
|
#[test]
|
2021-04-07 00:57:30 +00:00
|
|
|
#[cfg(all(feature = "mp3", feature = "flac"))]
|
2020-10-27 15:00:22 +00:00
|
|
|
fn test_inner() {
|
2021-04-03 00:47:44 +00:00
|
|
|
let mut innertag = metaflac::Tag::default();
|
|
|
|
innertag
|
|
|
|
.vorbis_comments_mut()
|
|
|
|
.set_title(vec!["title from metaflac::Tag"]);
|
|
|
|
let tag: FlacTag = innertag.into();
|
|
|
|
let mut id3tag = tag.to_dyn_tag(TagType::Id3v2);
|
|
|
|
id3tag
|
2021-04-06 20:37:31 +00:00
|
|
|
.write_to_path("tests/assets/a.mp3")
|
2021-04-03 00:47:44 +00:00
|
|
|
.expect("Fail to write!");
|
2020-10-27 15:00:22 +00:00
|
|
|
|
2021-04-03 00:47:44 +00:00
|
|
|
let id3tag_reload = Tag::default()
|
2021-04-06 20:37:31 +00:00
|
|
|
.read_from_path("tests/assets/a.mp3")
|
2021-04-03 00:47:44 +00:00
|
|
|
.expect("Fail to read!");
|
|
|
|
assert_eq!(id3tag_reload.title(), Some("title from metaflac::Tag"));
|
2020-10-27 15:24:54 +00:00
|
|
|
|
2021-04-03 00:47:44 +00:00
|
|
|
// let id3tag: Id3v2Tag = id3tag_reload.into();
|
|
|
|
let mut id3tag_inner: id3::Tag = id3tag_reload.into();
|
|
|
|
let timestamp = id3::Timestamp {
|
|
|
|
year: 2013,
|
|
|
|
month: Some(2u8),
|
|
|
|
day: Some(5u8),
|
|
|
|
hour: Some(6u8),
|
|
|
|
minute: None,
|
|
|
|
second: None,
|
|
|
|
};
|
|
|
|
id3tag_inner.set_date_recorded(timestamp.clone());
|
|
|
|
id3tag_inner
|
2021-04-06 20:37:31 +00:00
|
|
|
.write_to_path("tests/assets/a.mp3", id3::Version::Id3v24)
|
2021-04-03 00:47:44 +00:00
|
|
|
.expect("Fail to write!");
|
2020-10-27 15:24:54 +00:00
|
|
|
|
2021-04-06 20:37:31 +00:00
|
|
|
let id3tag_reload = id3::Tag::read_from_path("tests/assets/a.mp3").expect("Fail to read!");
|
2021-04-03 00:47:44 +00:00
|
|
|
assert_eq!(id3tag_reload.date_recorded(), Some(timestamp));
|
2020-10-27 15:00:22 +00:00
|
|
|
}
|