-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e88a94a
commit 16f32e1
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ mod test_speex; | |
mod test_wav; | ||
mod test_wavpack; | ||
mod test_xiphcomment; | ||
mod test_opus; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::temp_file; | ||
use lofty::ogg::OpusFile; | ||
use lofty::{Accessor, AudioFile, ParseOptions}; | ||
use std::io::Seek; | ||
|
||
#[test] | ||
fn test_audio_properties() { | ||
let mut file = temp_file!("tests/taglib/data/correctness_gain_silent_output.opus"); | ||
let f = OpusFile::read_from(&mut file, ParseOptions::new()).unwrap(); | ||
assert_eq!(f.properties().duration().as_secs(), 7); | ||
assert_eq!(f.properties().duration().as_millis(), 7737); | ||
assert_eq!(f.properties().audio_bitrate(), 36); | ||
assert_eq!(f.properties().channels(), 1); | ||
assert_eq!(f.properties().input_sample_rate(), 48000); | ||
assert_eq!(f.properties().version(), 1); | ||
} | ||
|
||
#[test] | ||
fn test_read_comments() { | ||
let mut file = temp_file!("tests/taglib/data/correctness_gain_silent_output.opus"); | ||
let f = OpusFile::read_from(&mut file, ParseOptions::new()).unwrap(); | ||
assert_eq!( | ||
f.vorbis_comments().get("ENCODER"), | ||
Some("Xiph.Org Opus testvectormaker") | ||
); | ||
assert!(f.vorbis_comments().get("TESTDESCRIPTION").is_some()); | ||
assert!(f.vorbis_comments().artist().is_none()); | ||
assert_eq!(f.vorbis_comments().vendor(), "libopus 0.9.11-66-g64c2dd7"); | ||
} | ||
|
||
#[test] | ||
fn test_write_comments() { | ||
let mut file = temp_file!("tests/taglib/data/correctness_gain_silent_output.opus"); | ||
|
||
{ | ||
let mut f = OpusFile::read_from(&mut file, ParseOptions::new()).unwrap(); | ||
file.rewind().unwrap(); | ||
f.vorbis_comments_mut() | ||
.set_artist(String::from("Your Tester")); | ||
f.save_to(&mut file).unwrap(); | ||
} | ||
file.rewind().unwrap(); | ||
{ | ||
let f = OpusFile::read_from(&mut file, ParseOptions::new()).unwrap(); | ||
assert_eq!( | ||
f.vorbis_comments().get("ENCODER"), | ||
Some("Xiph.Org Opus testvectormaker") | ||
); | ||
assert!(f.vorbis_comments().get("TESTDESCRIPTION").is_some()); | ||
assert_eq!(f.vorbis_comments().artist().as_deref(), Some("Your Tester")); | ||
assert_eq!(f.vorbis_comments().vendor(), "libopus 0.9.11-66-g64c2dd7"); | ||
} | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn test_split_packets() { | ||
// Marker test, Lofty does not retain packet information | ||
} |