Skip to content

Tests: Enable more TagLib tests #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions lofty/tests/taglib/test_aiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Seek;

use lofty::config::{ParseOptions, WriteOptions};
use lofty::file::{AudioFile, FileType};
use lofty::id3::v2::Id3v2Tag;
use lofty::id3::v2::{Id3v2Tag, Id3v2Version};
use lofty::iff::aiff::{AiffCompressionType, AiffFile};
use lofty::probe::Probe;
use lofty::tag::{Accessor, TagType};
Expand Down Expand Up @@ -96,9 +96,33 @@ fn test_save_id3v2() {
}

#[test_log::test]
#[ignore]
fn test_save_id3v23() {
todo!("Support writing ID3v2.3 tags")
let mut file = temp_file!("tests/taglib/data/empty.aiff");

let xxx = "X".repeat(254);
{
let mut tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();

assert!(tfile.id3v2().is_none());

let mut id3v2 = Id3v2Tag::new();
id3v2.set_title(xxx.clone());
id3v2.set_artist(String::from("Artist A"));
tfile.set_id3v2(id3v2);
file.rewind().unwrap();
tfile
.save_to(&mut file, WriteOptions::default().use_id3v23(true))
.unwrap();
assert!(tfile.contains_tag_type(TagType::Id3v2));
}
file.rewind().unwrap();
{
let tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();
let id3v2 = tfile.id3v2().unwrap().to_owned();
assert_eq!(id3v2.original_version(), Id3v2Version::V3);
assert_eq!(id3v2.artist().as_deref(), Some("Artist A"));
assert_eq!(id3v2.title().as_deref(), Some(&*xxx));
}
}

#[test_log::test]
Expand Down
2 changes: 0 additions & 2 deletions lofty/tests/taglib/test_fileref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,11 @@ fn test_mp4_1() {
}

#[test_log::test]
#[ignore] // TODO: The file has a malformed `free` atom. How does TagLib handle this? Currently we mess up entirely and just write a duplicate tag.
fn test_mp4_2() {
file_ref_save("no-tags.m4a", FileType::Mp4);
}

#[test_log::test]
#[ignore] // TODO: We are able to write the first tag and even reread, but the second save causes a `SizeMismatch`.
fn test_mp4_3() {
file_ref_save("no-tags.3g2", FileType::Mp4);
}
Expand Down
10 changes: 6 additions & 4 deletions lofty/tests/taglib/test_mpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ fn test_save_id3v24_wrong_param() {
// Marker test, Lofty does not replicate the TagLib saving API
}

// TODO: We don't yet support writing an ID3v23 tag (#62)
#[test_log::test]
#[ignore]
fn test_save_id3v23() {
let mut file = temp_file!("tests/taglib/data/xing.mp3");

Expand All @@ -154,7 +152,8 @@ fn test_save_id3v23() {
tag.set_title(xxx.clone());
tag.set_artist(String::from("Artist A"));
f.set_id3v2(tag);
f.save_to(&mut file, WriteOptions::default()).unwrap();
f.save_to(&mut file, WriteOptions::default().use_id3v23(true))
.unwrap();
}
file.rewind().unwrap();
{
Expand Down Expand Up @@ -216,7 +215,10 @@ fn test_strip_and_properties() {
}

#[test_log::test]
fn test_properties() {}
#[ignore]
fn test_properties() {
// Marker test, Lofty does not replicate the properties API
}

#[test_log::test]
#[ignore]
Expand Down