diff --git a/src/compiler.rs b/src/compiler.rs index cb54b78..a102322 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -437,7 +437,7 @@ impl Compiler { #[cfg(test)] mod tests { - use crate::compiler::{Compiler, Expression, SAMPLE_RATE, Silence}; + use crate::compiler::{Compiler, Expression, Note, SAMPLE_RATE, Silence}; use super::{CompilerError, Context}; @@ -464,7 +464,7 @@ mod tests { } #[test] - fn silence() -> Result<(), CompilerError> { + fn silence_renders_correct_amount_of_samples() -> Result<(), CompilerError> { assert_eq!( SAMPLE_RATE as usize, Compiler::from(context_generator()) @@ -475,4 +475,30 @@ mod tests { ); Ok(()) } + + #[test] + fn silence_renders_zeros() -> Result<(), CompilerError> { + assert!( + Compiler::from(context_generator()) + .apply_all(vec![Silence])? + .0 + .result + .into_iter() + .all(|s| s == 0f64) + ); + Ok(()) + } + + #[test] + fn note_renders_correct_amount_of_samples() -> Result<(), CompilerError> { + assert_eq!( + SAMPLE_RATE as usize, + Compiler::from(context_generator()) + .apply_all(vec![Note(2)])? + .0 + .result + .len() + ); + Ok(()) + } }