wrote a test but it doesn't work...
This commit is contained in:
parent
af7b4f77bb
commit
c58275dc75
2 changed files with 24 additions and 0 deletions
|
@ -19,3 +19,4 @@ derive-new = "0.7"
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
derive_wrapper = "0.1"
|
derive_wrapper = "0.1"
|
||||||
symphonia = { version = "0.5.4", features = ["all"] }
|
symphonia = { version = "0.5.4", features = ["all"] }
|
||||||
|
project-root = "0.2.2"
|
||||||
|
|
|
@ -41,6 +41,15 @@ pub enum AudioOpenError {
|
||||||
Symphonia(#[from] symphonia::core::errors::Error),
|
Symphonia(#[from] symphonia::core::errors::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq for AudioOpenError {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
match self {
|
||||||
|
AudioOpenError::Io(_) => matches!(other, AudioOpenError::Io(_)),
|
||||||
|
AudioOpenError::Symphonia(_) => matches!(other, AudioOpenError::Symphonia(_)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Audio {
|
impl Audio {
|
||||||
pub fn open<P: AsRef<Path>>(path: P) -> Result<Audio, AudioOpenError> {
|
pub fn open<P: AsRef<Path>>(path: P) -> Result<Audio, AudioOpenError> {
|
||||||
let registry = default::get_codecs();
|
let registry = default::get_codecs();
|
||||||
|
@ -159,3 +168,17 @@ where
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use project_root::get_project_root;
|
||||||
|
|
||||||
|
use crate::IntoDataBytes;
|
||||||
|
|
||||||
|
use super::Audio;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn open_sample_file() {
|
||||||
|
assert_eq!(Ok(include_bytes!("../../../testing material/sound/1938-04-30_BBC_Winston_Churchill_To_The_Royal_Academy_Of_Arts.mp3").to_vec()), Audio::open(get_project_root().expect("can't find project root!").join("testing material").join("sound").join("1938-04-30_BBC_Winston_Churchill_To_The_Royal_Academy_Of_Arts.mp3")).map(|audio| audio.into_data_bytes()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue