1#[macro_export]
71macro_rules! assert_audio_unit_snapshot {
72 ($unit:expr) => {{
74 let mut __unit = $unit;
76 let __unit_clone = __unit.clone();
77
78 let config = $crate::config::SnapshotConfigBuilder::default()
80 .build()
81 .unwrap();
82 let name = config.file_name(None);
83 let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
84
85 ::insta::with_settings!({ omit_expression => true}, {
86 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
87 });
88
89 let config = $crate::config::SnapshotConfigBuilder::default()
91 .output_mode($crate::config::WavOutput::Wav16)
92 .build()
93 .unwrap();
94 let name = config.file_name(None);
95 let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
96
97 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
98 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
99 });
100 }};
101
102 ($name:literal, $unit:expr) => {{
104 let mut __unit = $unit;
105 let __unit_clone = __unit.clone();
106
107 let config = $crate::config::SnapshotConfigBuilder::default()
109 .chart_title($name)
110 .build()
111 .unwrap();
112 let name = config.file_name(Some($name));
113 let data_svg = $crate::snapshot::snapshot_audio_unit_with_options(__unit, config);
114
115 ::insta::with_settings!({ omit_expression => true}, {
116 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
117 });
118
119 let config = $crate::config::SnapshotConfigBuilder::default()
121 .output_mode($crate::config::WavOutput::Wav16)
122 .build()
123 .unwrap();
124 let name = config.file_name(Some($name));
125 let data_wav = $crate::snapshot::snapshot_audio_unit_with_options(__unit_clone, config);
126
127 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
128 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
129 });
130 }};
131
132 ($name:literal, $unit:expr, $input:expr) => {{
134 let mut __unit = $unit;
135 let __unit_clone = __unit.clone();
136 let config = $crate::config::SnapshotConfigBuilder::default()
141 .chart_title($name)
142 .build()
143 .unwrap();
144 let name = config.file_name(Some($name));
145 let data_svg =
146 $crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit, $input, config);
147
148 ::insta::with_settings!({ omit_expression => true}, {
149 ::insta::assert_binary_snapshot!(&name, data_svg.as_slice().to_vec());
150 });
151
152 let config = $crate::config::SnapshotConfigBuilder::default()
154 .output_mode($crate::config::WavOutput::Wav16)
155 .build()
156 .unwrap();
157 let name = config.file_name(Some($name));
158 let data_wav =
159 $crate::snapshot::snapshot_audio_unit_with_input_and_options(__unit_clone, $input, config);
160
161 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
162 ::insta::assert_binary_snapshot!(&name, data_wav.as_slice().to_vec());
163 });
164 }};
165
166 ($name:literal, $unit:expr, $input:expr, $config:expr) => {{
168 let mut config = $config;
169 config.maybe_title($name);
170
171 let is_audio = matches!(
172 config.output_mode,
173 $crate::config::SnapshotOutputMode::Wav(_)
174 );
175
176 let name = config.file_name(Some($name));
177 let data = $crate::snapshot::snapshot_audio_unit_with_input_and_options($unit, $input, config);
178
179
180 if is_audio {
181 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
182 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
183 });
184 }
185 else {
186 ::insta::with_settings!({ omit_expression => true}, {
187 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
188 });
189 }
190 }};
191
192 ($unit:expr, $config:expr) => {{
194
195 let is_audio = matches!(
196 $config.output_mode,
197 $crate::config::SnapshotOutputMode::Wav(_)
198 );
199 let name = $config.file_name(None);
201 let data = $crate::snapshot::snapshot_audio_unit_with_options($unit, $config);
202
203 if is_audio {
204 ::insta::with_settings!({ omit_expression => true, snapshot_suffix => "audio" }, {
205 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
206 });
207 }
208 else {
209 ::insta::with_settings!({ omit_expression => true }, {
210 ::insta::assert_binary_snapshot!(&name, data.as_slice().to_vec());
211 });
212 }
213 }};
214}