Skip to content

Commit f69d795

Browse files
committed
Tests: Enable more TagLib tests
1 parent 56457c4 commit f69d795

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

lofty/tests/taglib/test_aiff.rs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::io::Seek;
55

66
use lofty::config::{ParseOptions, WriteOptions};
77
use lofty::file::{AudioFile, FileType};
8-
use lofty::id3::v2::Id3v2Tag;
8+
use lofty::id3::v2::{Id3v2Tag, Id3v2Version};
99
use lofty::iff::aiff::{AiffCompressionType, AiffFile};
1010
use lofty::probe::Probe;
1111
use lofty::tag::{Accessor, TagType};
@@ -96,9 +96,33 @@ fn test_save_id3v2() {
9696
}
9797

9898
#[test_log::test]
99-
#[ignore]
10099
fn test_save_id3v23() {
101-
todo!("Support writing ID3v2.3 tags")
100+
let mut file = temp_file!("tests/taglib/data/empty.aiff");
101+
102+
let xxx = "X".repeat(254);
103+
{
104+
let mut tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();
105+
106+
assert!(tfile.id3v2().is_none());
107+
108+
let mut id3v2 = Id3v2Tag::new();
109+
id3v2.set_title(xxx.clone());
110+
id3v2.set_artist(String::from("Artist A"));
111+
tfile.set_id3v2(id3v2);
112+
file.rewind().unwrap();
113+
tfile
114+
.save_to(&mut file, WriteOptions::default().use_id3v23(true))
115+
.unwrap();
116+
assert!(tfile.contains_tag_type(TagType::Id3v2));
117+
}
118+
file.rewind().unwrap();
119+
{
120+
let tfile = AiffFile::read_from(&mut file, ParseOptions::new()).unwrap();
121+
let id3v2 = tfile.id3v2().unwrap().to_owned();
122+
assert_eq!(id3v2.original_version(), Id3v2Version::V3);
123+
assert_eq!(id3v2.artist().as_deref(), Some("Artist A"));
124+
assert_eq!(id3v2.title().as_deref(), Some(&*xxx));
125+
}
102126
}
103127

104128
#[test_log::test]

lofty/tests/taglib/test_fileref.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ fn test_mp4_1() {
120120
}
121121

122122
#[test_log::test]
123-
#[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.
124123
fn test_mp4_2() {
125124
file_ref_save("no-tags.m4a", FileType::Mp4);
126125
}
127126

128127
#[test_log::test]
129-
#[ignore] // TODO: We are able to write the first tag and even reread, but the second save causes a `SizeMismatch`.
130128
fn test_mp4_3() {
131129
file_ref_save("no-tags.3g2", FileType::Mp4);
132130
}

lofty/tests/taglib/test_mpeg.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ fn test_save_id3v24_wrong_param() {
138138
// Marker test, Lofty does not replicate the TagLib saving API
139139
}
140140

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

@@ -154,7 +152,8 @@ fn test_save_id3v23() {
154152
tag.set_title(xxx.clone());
155153
tag.set_artist(String::from("Artist A"));
156154
f.set_id3v2(tag);
157-
f.save_to(&mut file, WriteOptions::default()).unwrap();
155+
f.save_to(&mut file, WriteOptions::default().use_id3v23(true))
156+
.unwrap();
158157
}
159158
file.rewind().unwrap();
160159
{
@@ -216,7 +215,10 @@ fn test_strip_and_properties() {
216215
}
217216

218217
#[test_log::test]
219-
fn test_properties() {}
218+
#[ignore]
219+
fn test_properties() {
220+
// Marker test, Lofty does not replicate the properties API
221+
}
220222

221223
#[test_log::test]
222224
#[ignore]

0 commit comments

Comments
 (0)