use core::panic;
use std::time::Duration;
use edar::{
extract_album, extract_artist, extract_bitrate, extract_channels, extract_cover,
extract_duration, extract_genre, extract_sample_rate, extract_title, extract_year,
};
#[test]
fn test_extract_title() {
match extract_title("tests/assets/test_song.mp3") {
Ok(title) => assert_eq!("A_Song", title),
Err(e) => panic!("Extract title failed: {e}"),
}
}
#[test]
fn test_extract_artist() {
match extract_artist("tests/assets/test_song.mp3") {
Ok(artist) => assert_eq!("darrkenn", artist),
Err(e) => panic!("Extract artist failed: {e}"),
}
}
#[test]
fn test_extract_album() {
match extract_album("tests/assets/test_song.mp3") {
Ok(album) => assert_eq!("A_Album", album),
Err(e) => panic!("Extract album failed: {e}"),
}
}
#[test]
fn test_extract_year() {
match extract_year("tests/assets/test_song.mp3") {
Ok(year) => assert_eq!("2020", year),
Err(e) => panic!("Extract year failed: {e}"),
}
}
#[test]
fn test_extract_genre() {
match extract_genre("tests/assets/test_song.mp3") {
Ok(genre) => assert_eq!("A_Genre", genre),
Err(e) => panic!("Extract genre failed: {e}"),
}
}
#[test]
fn test_extract_cover() {
match extract_cover("tests/assets/test_song.mp3") {
Ok(cover) => assert!(!cover.is_empty()),
Err(e) => panic!("Extract cover failed: {e}"),
}
}
#[test]
fn test_extract_duration() {
match extract_duration("tests/assets/test_song.mp3") {
Ok(duration) => {
let song_duration = Duration::from_secs(1) + Duration::from_millis(272);
assert_eq!(song_duration, duration)
}
Err(e) => panic!("Extract duration failed: {e}"),
}
}
#[test]
fn test_extract_sample_rate() {
match extract_sample_rate("tests/assets/test_song.mp3") {
Ok(sample_rate) => assert_eq!(48000, sample_rate),
Err(e) => panic!("Extract sample_rate failed: {e}"),
}
}
#[test]
fn test_extract_channels() {
match extract_channels("tests/assets/test_song.mp3") {
Ok(channels) => assert_eq!(1, channels),
Err(e) => panic!("Extract channels failed: {e}"),
}
}
#[test]
fn test_extract_bitrate() {
match extract_bitrate("tests/assets/test_song.mp3") {
Ok(bitrate) => assert_eq!(256, bitrate),
Err(e) => panic!("Extract bitrate failed: {e}"),
}
}