You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I'm new to Rust and audio plugin development, so forgive me if my questions are... basic? academic?
Anyway, while user-testing my plugin I discovered some behavior that suggested some of my functions were not returning what I expected. I wrote a few unit tests and found the problem. Encouraged by the immediate return on investment, I decided to write a bunch more tests.
For some of the tests, I don't need the plugin at all. For others, it suffices to call MyPlugin::default(). But I couldn't figure out how to instantiate the plugin with parameter values other than the default.
Here's a use case: MyPlugin has a chance parameter. If the user sets it to the minimum value, input will never be processed. I thought it would be useful to short-circuit some of the logic in my process method, so I wrote some code like this (abridged):
implMyPlugin{fnis_configured_to_act(&self) -> bool{// If the probability of intervention is set to zero...ifself.params.chance.value() == self.params.chance.default_plain_value()// ...then there is nothing for this plugin to do, because the output would always exactly match the input.{false}else{true}}}implPluginforMyPlugin{fn process(&mutself,_buffer:&mutBuffer,_aux:&mutAuxiliaryBuffers,context:&mutimplProcessContext<Self>,) -> ProcessStatus{whileletSome(event) = context.next_event(){match event {NoteEvent::NoteOn{
timing,
voice_id,
channel,
note,
velocity,} => {ifself.is_configured_to_act(){// do stuff}}// ...}}#[cfg(test)]mod tests {usesuper::*;#[test]fndoes_act_if_chance_is_nonzero(){let plugin = MyPlugin::default();// somehow change the param values programmatically?assert!(plugin.is_configured_to_act());}}
How would I write this test?
The text was updated successfully, but these errors were encountered:
Hello. I'm new to Rust and audio plugin development, so forgive me if my questions are... basic? academic?
Anyway, while user-testing my plugin I discovered some behavior that suggested some of my functions were not returning what I expected. I wrote a few unit tests and found the problem. Encouraged by the immediate return on investment, I decided to write a bunch more tests.
For some of the tests, I don't need the plugin at all. For others, it suffices to call
MyPlugin::default()
. But I couldn't figure out how to instantiate the plugin with parameter values other than the default.Here's a use case:
MyPlugin
has achance
parameter. If the user sets it to the minimum value, input will never be processed. I thought it would be useful to short-circuit some of the logic in myprocess
method, so I wrote some code like this (abridged):How would I write this test?
The text was updated successfully, but these errors were encountered: