Skip to content

Commit c7eb3b9

Browse files
committed
Tests: Update TagLib tests for recent ID3v2 changes
1 parent 8421534 commit c7eb3b9

File tree

7 files changed

+88
-85
lines changed

7 files changed

+88
-85
lines changed

tests/taglib/test_ape.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::io::Seek;
66
use std::time::Duration;
77

88
use lofty::ape::{ApeFile, ApeItem, ApeTag};
9-
use lofty::id3::v1::ID3v1Tag;
9+
use lofty::id3::v1::Id3v1Tag;
1010
use lofty::{Accessor, AudioFile, FileType, ItemValue, ParseOptions, TagExt};
1111

1212
fn test_399(path: &str) {
@@ -99,7 +99,7 @@ fn test_strip_and_properties() {
9999
ape_tag.set_title(String::from("APE"));
100100
ape_file.set_ape(ape_tag);
101101

102-
let mut id3v1_tag = ID3v1Tag::default();
102+
let mut id3v1_tag = Id3v1Tag::default();
103103
id3v1_tag.set_title(String::from("ID3v1"));
104104
ape_file.set_id3v1(id3v1_tag);
105105

@@ -363,7 +363,7 @@ fn test_repeated_save() {
363363
ape_file.save_to(&mut file).unwrap();
364364
file.rewind().unwrap();
365365

366-
let mut id3v1_tag = ID3v1Tag::default();
366+
let mut id3v1_tag = Id3v1Tag::default();
367367
id3v1_tag.set_title(String::from("01234 56789 ABCDE FGHIJ"));
368368
ape_file.set_id3v1(id3v1_tag);
369369
ape_file.ape_mut().unwrap().set_title(String::from(

tests/taglib/test_flac.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::temp_file;
33
use std::io::{Read, Seek, SeekFrom};
44

55
use lofty::flac::FlacFile;
6-
use lofty::id3::v2::ID3v2Tag;
6+
use lofty::id3::v2::Id3v2Tag;
77
use lofty::ogg::{OggPictureStorage, VorbisComments};
88
use lofty::{
99
Accessor, AudioFile, MimeType, ParseOptions, Picture, PictureInformation, PictureType, TagExt,
@@ -490,7 +490,7 @@ fn test_empty_id3v2() {
490490
let mut f = FlacFile::read_from(&mut file, ParseOptions::new()).unwrap();
491491
file.rewind().unwrap();
492492

493-
f.set_id3v2(ID3v2Tag::default());
493+
f.set_id3v2(Id3v2Tag::default());
494494
f.save_to(&mut file).unwrap();
495495
}
496496
file.rewind().unwrap();

tests/taglib/test_id3v1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::temp_file;
22

33
use std::io::Seek;
44

5-
use lofty::id3::v1::{ID3v1Tag, GENRES};
5+
use lofty::id3::v1::{Id3v1Tag, GENRES};
66
use lofty::mpeg::MpegFile;
77
use lofty::{Accessor, AudioFile, ParseOptions};
88

@@ -14,7 +14,7 @@ fn test_strip_whitespace() {
1414
let mut f = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
1515
file.rewind().unwrap();
1616

17-
let mut tag = ID3v1Tag::default();
17+
let mut tag = Id3v1Tag::default();
1818
tag.set_artist(String::from("Artist "));
1919
f.set_id3v1(tag);
2020
f.save_to(&mut file).unwrap();

tests/taglib/test_id3v2.rs

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use crate::temp_file;
22
use lofty::id3::v2::{
33
AttachedPictureFrame, CommentFrame, ExtendedTextFrame, ExtendedUrlFrame, Frame, FrameFlags,
4-
FrameId, FrameValue, GEOBInformation, GeneralEncapsulatedObject, ID3v2Tag, ID3v2Version,
5-
Popularimeter, SyncTextContentType, SyncTextInformation, SynchronizedText, TimestampFormat,
6-
UniqueFileIdentifierFrame, UrlLinkFrame,
4+
FrameId, FrameValue, GeneralEncapsulatedObject, Id3v2Tag, Id3v2Version, Popularimeter,
5+
SyncTextContentType, SynchronizedText, TimestampFormat, UniqueFileIdentifierFrame,
6+
UrlLinkFrame,
77
};
88
use lofty::mpeg::MpegFile;
99
use lofty::{
10-
Accessor, AudioFile, MimeType, ParseOptions, Picture, PictureType, TagExt, TextEncoding,
10+
Accessor, AudioFile, MimeType, ParseOptions, ParsingMode, Picture, PictureType, TagExt,
11+
TextEncoding,
1112
};
1213
use std::borrow::Cow;
1314
use std::io::Seek;
@@ -60,13 +61,13 @@ fn test_read_string_field() {
6061
#[test]
6162
fn test_parse_apic() {
6263
let f = AttachedPictureFrame::parse(
63-
b"\
64+
&mut &b"\
6465
\x00\
6566
m\x00\
6667
\x01\
6768
d\x00\
68-
\x00",
69-
ID3v2Version::V4,
69+
\x00"[..],
70+
Id3v2Version::V4,
7071
)
7172
.unwrap();
7273
assert_eq!(f.picture.mime_type(), &MimeType::Unknown(String::from("m")));
@@ -77,11 +78,11 @@ fn test_parse_apic() {
7778
#[test]
7879
fn test_parse_apic_utf16_bom() {
7980
let f = AttachedPictureFrame::parse(
80-
b"\
81+
&mut &b"\
8182
\x01\x69\x6d\x61\x67\x65\
8283
\x2f\x6a\x70\x65\x67\x00\x00\xfe\xff\x00\x63\x00\x6f\x00\x76\x00\
83-
\x65\x00\x72\x00\x2e\x00\x6a\x00\x70\x00\x67\x00\x00\xff\xd8\xff",
84-
ID3v2Version::V4,
84+
\x65\x00\x72\x00\x2e\x00\x6a\x00\x70\x00\x67\x00\x00\xff\xd8\xff"[..],
85+
Id3v2Version::V4,
8586
)
8687
.unwrap();
8788

@@ -94,13 +95,13 @@ fn test_parse_apic_utf16_bom() {
9495
#[test]
9596
fn test_parse_apicv22() {
9697
let frame = AttachedPictureFrame::parse(
97-
b"\
98+
&mut &b"\
9899
\x00\
99100
JPG\
100101
\x01\
101102
d\x00\
102-
\x00",
103-
ID3v2Version::V2,
103+
\x00"[..],
104+
Id3v2Version::V2,
104105
)
105106
.unwrap();
106107

@@ -122,7 +123,7 @@ fn test_render_apic() {
122123
};
123124

124125
assert_eq!(
125-
f.as_bytes(ID3v2Version::V4).unwrap(),
126+
f.as_bytes(Id3v2Version::V4).unwrap(),
126127
b"\
127128
\x03\
128129
image/png\x00\
@@ -149,20 +150,18 @@ fn test_parse_geob() {
149150
\x00",
150151
)
151152
.unwrap();
152-
assert_eq!(f.information.mime_type.as_deref(), Some("m"));
153-
assert_eq!(f.information.file_name.as_deref(), Some("f"));
154-
assert_eq!(f.information.descriptor.as_deref(), Some("d"));
153+
assert_eq!(f.mime_type.as_deref(), Some("m"));
154+
assert_eq!(f.file_name.as_deref(), Some("f"));
155+
assert_eq!(f.descriptor.as_deref(), Some("d"));
155156
}
156157

157158
#[test]
158159
fn test_render_geob() {
159160
let f = GeneralEncapsulatedObject {
160-
information: GEOBInformation {
161-
encoding: TextEncoding::Latin1,
162-
mime_type: Some(String::from("application/octet-stream")),
163-
file_name: Some(String::from("test.bin")),
164-
descriptor: Some(String::from("Description")),
165-
},
161+
encoding: TextEncoding::Latin1,
162+
mime_type: Some(String::from("application/octet-stream")),
163+
file_name: Some(String::from("test.bin")),
164+
descriptor: Some(String::from("Description")),
166165
data: vec![0x01; 3],
167166
};
168167

@@ -180,10 +179,10 @@ fn test_render_geob() {
180179
#[test]
181180
fn test_parse_popm() {
182181
let f = Popularimeter::parse(
183-
b"\
182+
&mut &b"\
184183
email@example.com\x00\
185184
\x02\
186-
\x00\x00\x00\x03",
185+
\x00\x00\x00\x03"[..],
187186
)
188187
.unwrap();
189188
assert_eq!(f.email, "email@example.com");
@@ -194,9 +193,9 @@ fn test_parse_popm() {
194193
#[test]
195194
fn test_parse_popm_without_counter() {
196195
let f = Popularimeter::parse(
197-
b"\
196+
&mut &b"\
198197
email@example.com\x00\
199-
\x02",
198+
\x02"[..],
200199
)
201200
.unwrap();
202201
assert_eq!(f.email, "email@example.com");
@@ -241,7 +240,7 @@ fn test_popm_from_file() {
241240
let mut foo = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
242241
file.rewind().unwrap();
243242

244-
let mut tag = ID3v2Tag::new();
243+
let mut tag = Id3v2Tag::new();
245244
tag.insert(
246245
Frame::new("POPM", FrameValue::Popularimeter(f), FrameFlags::default()).unwrap(),
247246
);
@@ -276,6 +275,7 @@ fn test_parse_unique_file_identifier_frame() {
276275
&mut &b"\
277276
owner\x00\
278277
\x00\x01\x02"[..],
278+
ParsingMode::Strict,
279279
)
280280
.unwrap()
281281
.unwrap();
@@ -290,6 +290,7 @@ fn test_parse_empty_unique_file_identifier_frame() {
290290
&mut &b"\
291291
\x00\
292292
"[..],
293+
ParsingMode::Strict,
293294
);
294295

295296
// NOTE: TagLib considers a missing owner to be valid, we do not
@@ -313,24 +314,28 @@ owner\x00\
313314

314315
#[test]
315316
fn test_parse_url_link_frame() {
316-
let f = UrlLinkFrame::parse(b"http://example.com").unwrap().unwrap();
317+
let f = UrlLinkFrame::parse(&mut &b"http://example.com"[..])
318+
.unwrap()
319+
.unwrap();
317320
assert_eq!(f.url(), "http://example.com");
318321
}
319322

320323
#[test]
321324
fn test_render_url_link_frame() {
322-
let f = UrlLinkFrame::parse(b"http://example.com").unwrap().unwrap();
325+
let f = UrlLinkFrame::parse(&mut &b"http://example.com"[..])
326+
.unwrap()
327+
.unwrap();
323328
assert_eq!(f.as_bytes(), b"http://example.com");
324329
}
325330

326331
#[test]
327332
fn test_parse_user_url_link_frame() {
328333
let f = ExtendedUrlFrame::parse(
329-
b"\
334+
&mut &b"\
330335
\x00\
331336
foo\x00\
332-
http://example.com",
333-
ID3v2Version::V4,
337+
http://example.com"[..],
338+
Id3v2Version::V4,
334339
)
335340
.unwrap()
336341
.unwrap();
@@ -380,11 +385,11 @@ Lyrics\x00\
380385
)
381386
.unwrap();
382387

383-
assert_eq!(f.information.encoding, TextEncoding::Latin1);
384-
assert_eq!(f.information.language, *b"eng");
385-
assert_eq!(f.information.timestamp_format, TimestampFormat::MS);
386-
assert_eq!(f.information.content_type, SyncTextContentType::Lyrics);
387-
assert_eq!(f.information.description.as_deref(), Some("foo"));
388+
assert_eq!(f.encoding, TextEncoding::Latin1);
389+
assert_eq!(f.language, *b"eng");
390+
assert_eq!(f.timestamp_format, TimestampFormat::MS);
391+
assert_eq!(f.content_type, SyncTextContentType::Lyrics);
392+
assert_eq!(f.description.as_deref(), Some("foo"));
388393

389394
assert_eq!(f.content.len(), 2);
390395
assert_eq!(f.content[0].1, "Example");
@@ -409,11 +414,11 @@ fn test_parse_synchronized_lyrics_frame_with_empty_description() {
409414
)
410415
.unwrap();
411416

412-
assert_eq!(f.information.encoding, TextEncoding::Latin1);
413-
assert_eq!(f.information.language, *b"eng");
414-
assert_eq!(f.information.timestamp_format, TimestampFormat::MS);
415-
assert_eq!(f.information.content_type, SyncTextContentType::Lyrics);
416-
assert!(f.information.description.is_none());
417+
assert_eq!(f.encoding, TextEncoding::Latin1);
418+
assert_eq!(f.language, *b"eng");
419+
assert_eq!(f.timestamp_format, TimestampFormat::MS);
420+
assert_eq!(f.content_type, SyncTextContentType::Lyrics);
421+
assert!(f.description.is_none());
417422

418423
assert_eq!(f.content.len(), 2);
419424
assert_eq!(f.content[0].1, "Example");
@@ -425,13 +430,11 @@ fn test_parse_synchronized_lyrics_frame_with_empty_description() {
425430
#[test]
426431
fn test_render_synchronized_lyrics_frame() {
427432
let f = SynchronizedText {
428-
information: SyncTextInformation {
429-
encoding: TextEncoding::Latin1,
430-
language: *b"eng",
431-
timestamp_format: TimestampFormat::MS,
432-
content_type: SyncTextContentType::Lyrics,
433-
description: Some(String::from("foo")),
434-
},
433+
encoding: TextEncoding::Latin1,
434+
language: *b"eng",
435+
timestamp_format: TimestampFormat::MS,
436+
content_type: SyncTextContentType::Lyrics,
437+
description: Some(String::from("foo")),
435438
content: vec![
436439
(1234, String::from("Example")),
437440
(4567, String::from("Lyrics")),
@@ -464,11 +467,11 @@ fn test_render_event_timing_codes_frame() {}
464467
#[test]
465468
fn test_parse_comments_frame() {
466469
let f = CommentFrame::parse(
467-
b"\x03\
470+
&mut &b"\x03\
468471
deu\
469472
Description\x00\
470-
Text",
471-
ID3v2Version::V4,
473+
Text"[..],
474+
Id3v2Version::V4,
472475
)
473476
.unwrap()
474477
.unwrap();
@@ -521,11 +524,11 @@ fn test_render_private_frame() {}
521524
#[test]
522525
fn test_parse_user_text_identification_frame() {
523526
let frame_without_description = ExtendedUrlFrame::parse(
524-
b"\
527+
&mut &b"\
525528
\x00\
526529
\x00\
527-
Text",
528-
ID3v2Version::V4,
530+
Text"[..],
531+
Id3v2Version::V4,
529532
)
530533
.unwrap()
531534
.unwrap();
@@ -534,11 +537,11 @@ fn test_parse_user_text_identification_frame() {
534537
assert_eq!(frame_without_description.content, String::from("Text"));
535538

536539
let frame_with_description = ExtendedUrlFrame::parse(
537-
b"\
540+
&mut &b"\
538541
\x00\
539542
Description\x00\
540-
Text",
541-
ID3v2Version::V4,
543+
Text"[..],
544+
Id3v2Version::V4,
542545
)
543546
.unwrap()
544547
.unwrap();
@@ -601,7 +604,7 @@ fn test_save_utf16_comment() {
601604
let mut foo = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
602605
file.rewind().unwrap();
603606

604-
let mut tag = ID3v2Tag::new();
607+
let mut tag = Id3v2Tag::new();
605608
tag.insert(
606609
Frame::new(
607610
"COMM",
@@ -761,7 +764,7 @@ fn test_save_and_strip_id3v1_should_not_add_frame_from_id3v1_to_id3v2() {
761764
let mut foo = MpegFile::read_from(&mut file, ParseOptions::new()).unwrap();
762765
file.rewind().unwrap();
763766

764-
let mut tag = ID3v2Tag::new();
767+
let mut tag = Id3v2Tag::new();
765768
tag.set_artist(String::from("Artist"));
766769
foo.set_id3v2(tag);
767770
foo.save_to(&mut file).unwrap();

0 commit comments

Comments
 (0)