Revision 34:a2d9aed55a2a TestDefaults.cpp
| TestDefaults.cpp | ||
|---|---|---|
| 58 | 58 |
Tester::TestRegistrar<TestDefaultParameters> |
| 59 | 59 |
TestDefaultParameters::m_registrar("E2 Inconsistent default parameters");
|
| 60 | 60 |
|
| 61 |
Tester::TestRegistrar<TestParametersOnReset> |
|
| 62 |
TestParametersOnReset::m_registrar("E3 Parameter retention through reset");
|
|
| 63 |
|
|
| 61 | 64 |
static const size_t _step = 1000; |
| 62 | 65 |
|
| 63 | 66 |
Test::Results |
| ... | ... | |
| 168 | 171 |
|
| 169 | 172 |
return r; |
| 170 | 173 |
} |
| 174 |
|
|
| 175 |
Test::Results |
|
| 176 |
TestParametersOnReset::test(string key, Options options) |
|
| 177 |
{
|
|
| 178 |
Plugin::FeatureSet f[2]; |
|
| 179 |
int rate = 44100; |
|
| 180 |
Results r; |
|
| 181 |
float **data = 0; |
|
| 182 |
size_t channels = 0; |
|
| 183 |
size_t count = 100; |
|
| 184 |
|
|
| 185 |
for (int run = 0; run < 2; ++run) {
|
|
| 186 |
auto_ptr<Plugin> p(load(key, rate)); |
|
| 187 |
if (p->getParameterDescriptors().empty()) return r; |
|
| 188 |
|
|
| 189 |
// Set all parameters to non-default values |
|
| 190 |
Plugin::ParameterList pl = p->getParameterDescriptors(); |
|
| 191 |
for (int i = 0; i < (int)pl.size(); ++i) {
|
|
| 192 |
if (pl[i].defaultValue == pl[i].minValue) {
|
|
| 193 |
p->setParameter(pl[i].identifier, pl[i].maxValue); |
|
| 194 |
} else {
|
|
| 195 |
p->setParameter(pl[i].identifier, pl[i].minValue); |
|
| 196 |
} |
|
| 197 |
} |
|
| 198 |
|
|
| 199 |
if (!initAdapted(p.get(), channels, _step, _step, r)) return r; |
|
| 200 |
|
|
| 201 |
// First run: construct, set params, init, process |
|
| 202 |
// Second run: construct, set params, init, reset, process |
|
| 203 |
// We expect these to produce the same results |
|
| 204 |
if (run == 1) p->reset(); |
|
| 205 |
|
|
| 206 |
if (!data) data = createTestAudio(channels, _step, count); |
|
| 207 |
for (size_t i = 0; i < count; ++i) {
|
|
| 208 |
#ifdef __GNUC__ |
|
| 209 |
float *ptr[channels]; |
|
| 210 |
#else |
|
| 211 |
float **ptr = (float **)alloca(channels * sizeof(float)); |
|
| 212 |
#endif |
|
| 213 |
size_t idx = i * _step; |
|
| 214 |
for (size_t c = 0; c < channels; ++c) ptr[c] = data[c] + idx; |
|
| 215 |
RealTime timestamp = RealTime::frame2RealTime(idx, rate); |
|
| 216 |
Plugin::FeatureSet fs = p->process(ptr, timestamp); |
|
| 217 |
appendFeatures(f[run], fs); |
|
| 218 |
} |
|
| 219 |
Plugin::FeatureSet fs = p->getRemainingFeatures(); |
|
| 220 |
appendFeatures(f[run], fs); |
|
| 221 |
} |
|
| 222 |
if (data) destroyTestAudio(data, channels); |
|
| 223 |
|
|
| 224 |
if (!(f[0] == f[1])) {
|
|
| 225 |
string message = "Call to reset after setting parameters, but before processing, changes the results (parameter values not retained through reset?)"; |
|
| 226 |
Result res; |
|
| 227 |
if (options & NonDeterministic) res = note(message); |
|
| 228 |
else res = error(message); |
|
| 229 |
if (options & Verbose) dump(res, f[0], f[1]); |
|
| 230 |
r.push_back(res); |
|
| 231 |
} else {
|
|
| 232 |
r.push_back(success()); |
|
| 233 |
} |
|
| 234 |
|
|
| 235 |
return r; |
|
| 236 |
} |
|
Also available in: Unified diff