#[macro_export]
macro_rules! assert_audio_unit_snapshot {
($unit:expr) => {{
let mut __unit = $unit;
let __unit_clone = __unit.clone();
let config = $crate::config::SnapshotConfigBuilder::default()
.build()
.unwrap();
let name = config.file_name(None);
let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
::insta::with_settings!({ omit_expression => true}, {
::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
});
let config = $crate::config::SnapshotConfigBuilder::default()
.output_mode($crate::config::WavOutput::Wav16)
.build()
.unwrap();
let name = config.file_name(None);
let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
});
}};
($name:literal, $unit:expr) => {{
let mut __unit = $unit;
let __unit_clone = __unit.clone();
let config = $crate::config::SnapshotConfigBuilder::default()
.chart_title($name)
.build()
.unwrap();
let name = config.file_name(Some($name));
let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
::insta::with_settings!({ omit_expression => true}, {
::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
});
let config = $crate::config::SnapshotConfigBuilder::default()
.output_mode($crate::config::WavOutput::Wav16)
.build()
.unwrap();
let name = config.file_name(Some($name));
let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
});
}};
($name:expr, $unit:expr, $input:expr) => {{
let __name: String = ::std::convert::Into::into($name);
let mut __unit = $unit;
let __unit_clone = __unit.clone();
let config = $crate::config::SnapshotConfigBuilder::default()
.chart_title(__name.as_str())
.build()
.unwrap();
let name = config.file_name(Some(__name.as_str()));
let data_svg =
$crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit, $input, config);
::insta::with_settings!({ omit_expression => true}, {
::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
});
let config = $crate::config::SnapshotConfigBuilder::default()
.output_mode($crate::config::WavOutput::Wav16)
.build()
.unwrap();
let name = config.file_name(Some(__name.as_str()));
let data_wav =
$crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit_clone, $input, config);
::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
});
}};
($name:expr, $unit:expr, $input:expr, $config:expr) => {{
let __name: String = ::std::convert::Into::into($name);
let mut config = $config;
config.maybe_title(__name.as_str());
let is_audio = matches!(
config.output_mode,
$crate::config::SnapshotOutputMode::Wav(_)
);
let name = config.file_name(Some(__name.as_str()));
let data = $crate::snapshot::snapshot_audio_unit_with_input_and_options($unit, $input, config);
if is_audio {
::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
});
}
else {
::insta::with_settings!({ omit_expression => true}, {
::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
});
}
}};
($unit:expr, $config:expr) => {{
let is_audio = matches!(
$config.output_mode,
$crate::config::SnapshotOutputMode::Wav(_)
);
let name = $config.file_name(None);
let data = $crate::snapshot::snapshot_audio_unit_with_options($unit, $config);
if is_audio {
::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
});
}
else {
::insta::with_settings!({ omit_expression => true }, {
::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
});
}
}};
}
#[macro_export]
macro_rules! assert_dsp_net_snapshot {
($name:expr, $net:expr) => {{
let __name: String = ::std::convert::Into::into($name);
let __snap_name = format!("{}.dot", __name);
let __bytes: ::std::vec::Vec<u8> = $crate::graph::snapshot_dsp_net_wiring($net);
::insta::with_settings!({ omit_expression => true }, {
::insta::assert_binary_snapshot!(&__snap_name, __bytes);
});
}};
}