Skip to content

Commit f4a6aa9

Browse files
committed
Tests: Add TagLib ID3v1 tests
1 parent cf819a6 commit f4a6aa9

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/taglib/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ mod test_apetag;
66
mod test_fileref;
77
mod test_flac;
88
mod test_flacpicture;
9+
mod test_id3v1;

tests/taglib/test_id3v1.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
use crate::temp_file;
2+
3+
use std::io::Seek;
4+
5+
use lofty::id3::v1::{ID3v1Tag, GENRES};
6+
use lofty::mpeg::MPEGFile;
7+
use lofty::{Accessor, AudioFile, ParseOptions};
8+
9+
#[test]
10+
#[ignore] // TODO: We probably should be stripping whitespace
11+
fn test_strip_whitespace() {
12+
let mut file = temp_file!("tests/taglib/data/xing.mp3");
13+
{
14+
let mut f = MPEGFile::read_from(&mut file, ParseOptions::new()).unwrap();
15+
file.rewind().unwrap();
16+
17+
let mut tag = ID3v1Tag::default();
18+
tag.set_artist(String::from("Artist "));
19+
f.set_id3v1(tag);
20+
f.save_to(&mut file).unwrap();
21+
}
22+
file.rewind().unwrap();
23+
{
24+
let f = MPEGFile::read_from(&mut file, ParseOptions::new()).unwrap();
25+
assert_eq!(f.id3v1().unwrap().artist().as_deref(), Some("Artist"));
26+
}
27+
}
28+
29+
#[test]
30+
fn test_genres() {
31+
assert_eq!("Darkwave", GENRES[50]);
32+
assert_eq!(
33+
100,
34+
GENRES.iter().position(|genre| *genre == "Humour").unwrap()
35+
);
36+
assert!(GENRES.contains(&"Heavy Metal"));
37+
assert_eq!(
38+
79,
39+
GENRES
40+
.iter()
41+
.position(|genre| *genre == "Hard Rock")
42+
.unwrap()
43+
);
44+
}
45+
46+
#[test]
47+
#[ignore]
48+
fn test_renamed_genres() {
49+
// Marker test, this covers a change where TagLib deviated from the list of genres available on Wikipedia.
50+
// For now, Lofty has no reason to change.
51+
}

0 commit comments

Comments
 (0)