Skip to content

Commit

Permalink
Tests: Add TagLib ID3v1 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Serial-ATA committed Jan 15, 2023
1 parent f60245f commit 3179959
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/taglib/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ mod test_apetag;
mod test_fileref;
mod test_flac;
mod test_flacpicture;
mod test_id3v1;
51 changes: 51 additions & 0 deletions tests/taglib/test_id3v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
use crate::temp_file;

use std::io::Seek;

use lofty::id3::v1::{ID3v1Tag, GENRES};
use lofty::mpeg::MPEGFile;
use lofty::{Accessor, AudioFile, ParseOptions};

#[test]
#[ignore] // TODO: We probably should be stripping whitespace
fn test_strip_whitespace() {
let mut file = temp_file!("tests/taglib/data/xing.mp3");
{
let mut f = MPEGFile::read_from(&mut file, ParseOptions::new()).unwrap();
file.rewind().unwrap();

let mut tag = ID3v1Tag::default();
tag.set_artist(String::from("Artist "));
f.set_id3v1(tag);
f.save_to(&mut file).unwrap();
}
file.rewind().unwrap();
{
let f = MPEGFile::read_from(&mut file, ParseOptions::new()).unwrap();
assert_eq!(f.id3v1().unwrap().artist().as_deref(), Some("Artist"));
}
}

#[test]
fn test_genres() {
assert_eq!("Darkwave", GENRES[50]);
assert_eq!(
100,
GENRES.iter().position(|genre| *genre == "Humour").unwrap()
);
assert!(GENRES.contains(&"Heavy Metal"));
assert_eq!(
79,
GENRES
.iter()
.position(|genre| *genre == "Hard Rock")
.unwrap()
);
}

#[test]
#[ignore]
fn test_renamed_genres() {
// Marker test, this covers a change where TagLib deviated from the list of genres available on Wikipedia.
// For now, Lofty has no reason to change.
}

0 comments on commit 3179959

Please sign in to comment.