| 186 | |
| 187 | template <class ExpectedSample, class ActualSample> |
| 188 | void CompareMagnitudeData( |
| 189 | const std::vector<std::vector<complex<ExpectedSample>>>& |
| 190 | expected_complex_output, |
| 191 | const std::vector<std::vector<ActualSample>>& actual_squared_magnitude, |
| 192 | double tolerance) { |
| 193 | ASSERT_EQ(actual_squared_magnitude.size(), expected_complex_output.size()); |
| 194 | for (int i = 0; i < expected_complex_output.size(); ++i) { |
| 195 | ASSERT_EQ(expected_complex_output[i].size(), |
| 196 | actual_squared_magnitude[i].size()); |
| 197 | for (int j = 0; j < expected_complex_output[i].size(); ++j) { |
| 198 | ASSERT_NEAR(norm(expected_complex_output[i][j]), |
| 199 | actual_squared_magnitude[i][j], tolerance) |
| 200 | << ": where i=" << i << " and j=" << j << "."; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | TEST(SpectrogramTest, ReInitializationWorks) { |
| 206 | Spectrogram sgram; |