Skip to content

Commit

Permalink
Merge pull request #86 from Polochon-street/more-test-coverage
Browse files Browse the repository at this point in the history
Write more tests
  • Loading branch information
Polochon-street authored Sep 13, 2024
2 parents 2efd280 + 065ed90 commit 93e7523
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ask questions if you want to tackle an item.
Hopefully will make playlists not drift
- Improve bliss-python somehow / use it in a small demo project maybe?
A blissify in python?
- Investigate what type SAMPLE_RATE is in Aubio - maybe u16 is enough

## Done
- Split out ffmpeg (see https://github.com/Polochon-street/bliss-rs/issues/63 and https://users.rust-lang.org/t/proper-way-to-abstract-a-third-party-provider/107076/8)
Expand Down
10 changes: 10 additions & 0 deletions src/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ mod tests {
assert!(0.01 > (0.378605 - tempo_desc.get_value()).abs());
}

#[test]
fn test_tempo_error_creating_aubio_tempo() {
assert_eq!(
BPMDesc::new(0).err().unwrap(),
BlissError::AnalysisError(String::from(
"error while loading aubio tempo object: creation error"
))
)
}

#[test]
fn test_tempo_artificial() {
let mut tempo_desc = BPMDesc::new(22050).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/timbral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ mod tests {

#[test]
fn test_zcr_boundaries() {
let mut zcr_desc = ZeroCrossingRateDesc::default();
let mut zcr_desc = ZeroCrossingRateDesc::new(SAMPLE_RATE);
let chunk = vec![0.; 1024];
zcr_desc.do_(&chunk);
assert_eq!(-1., zcr_desc.get_value());
Expand All @@ -278,7 +278,7 @@ mod tests {
.flatten()
.cloned()
.collect::<Vec<f32>>();
let mut zcr_desc = ZeroCrossingRateDesc::default();
let mut zcr_desc = ZeroCrossingRateDesc::new(SAMPLE_RATE);
zcr_desc.do_(&chunks);
assert!(0.001 > (0.9980469 - zcr_desc.get_value()).abs());
}
Expand Down

0 comments on commit 93e7523

Please sign in to comment.