From c96bce8b3709a3cda2ebe119fdd24aa480057c38 Mon Sep 17 00:00:00 2001 From: brevalferrari Date: Wed, 28 May 2025 16:58:58 +0200 Subject: [PATCH] =?UTF-8?q?replace=20=CF=80,=20more=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compiler.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) 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(()) + } }