Mercurial > hg > vamp-plugin-tester
comparison Test.cpp @ 61:c7fd03f5ae02
Show feature diffs
author | Chris Cannam |
---|---|
date | Tue, 08 Sep 2015 11:28:42 +0100 |
parents | 86d8a699dfbe |
children |
comparison
equal
deleted
inserted
replaced
60:9f2a6d843639 | 61:c7fd03f5ae02 |
---|---|
190 } | 190 } |
191 return false; | 191 return false; |
192 } | 192 } |
193 | 193 |
194 void | 194 void |
195 Test::dumpFeature(const Plugin::Feature &f, bool showValues) | 195 Test::dumpFeature(const Plugin::Feature &f, bool showValues, |
196 const Plugin::Feature *other) | |
196 { | 197 { |
197 cout << " Timestamp: " << (!f.hasTimestamp ? "(none)" : f.timestamp.toText()) << endl; | 198 cout << " Timestamp: " << (!f.hasTimestamp ? "(none)" : f.timestamp.toText()) << endl; |
198 cout << " Duration: " << (!f.hasDuration ? "(none)" : f.duration.toText()) << endl; | 199 cout << " Duration: " << (!f.hasDuration ? "(none)" : f.duration.toText()) << endl; |
199 cout << " Label: " << (f.label == "" ? "(none)" : f.label) << endl; | 200 cout << " Label: " << (f.label == "" ? "(none)" : f.label) << endl; |
200 if (showValues) { | 201 if (showValues) { |
201 cout << " Values (" << f.values.size() << "): " << (f.values.empty() ? "(none)" : ""); | 202 cout << " Values (" << f.values.size() << "): " << (f.values.empty() ? "(none)" : ""); |
202 for (int j = 0; j < (int)f.values.size(); ++j) { | 203 int n = f.values.size(); |
203 cout << f.values[j] << " "; | 204 if (!other) { |
205 for (int j = 0; j < n; ++j) { | |
206 cout << f.values[j] << " "; | |
207 } | |
208 } else { | |
209 int samecount = 0; | |
210 int diffcount = 0; | |
211 for (int j = 0; j <= n; ++j) { | |
212 if (j < n && f.values[j] == other->values[j]) { | |
213 ++samecount; | |
214 } else { | |
215 if (samecount > 0) { | |
216 cout << "(" << samecount << " identical) "; | |
217 } | |
218 samecount = 0; | |
219 if (j < n) { | |
220 ++diffcount; | |
221 if (diffcount > 20 && j + 10 < n) { | |
222 cout << "(remaining " << n - j << " values elided)"; | |
223 break; | |
224 } else { | |
225 cout << f.values[j] << " [diff " | |
226 << f.values[j] - other->values[j] << "] "; | |
227 } | |
228 } | |
229 } | |
230 } | |
204 } | 231 } |
205 cout << endl; | 232 cout << endl; |
206 } else { | 233 } else { |
207 cout << " Values (" << f.values.size() << "): (elided)" << endl; | 234 cout << " Values (" << f.values.size() << "): (elided)" << endl; |
208 } | 235 } |
269 Plugin::FeatureList::const_iterator afi = ai->second.begin(); | 296 Plugin::FeatureList::const_iterator afi = ai->second.begin(); |
270 Plugin::FeatureList::const_iterator bfi = bi->second.begin(); | 297 Plugin::FeatureList::const_iterator bfi = bi->second.begin(); |
271 while (afi != ai->second.end()) { | 298 while (afi != ai->second.end()) { |
272 if (!(*afi == *bfi)) { | 299 if (!(*afi == *bfi)) { |
273 if (diffcount == 0) { | 300 if (diffcount == 0) { |
274 bool differInValues = (afi->values != bfi->values); | 301 bool differInValues = |
302 (afi->values.size() == bfi->values.size() && | |
303 afi->values != bfi->values); | |
275 if (afi->hasTimestamp != bfi->hasTimestamp) { | 304 if (afi->hasTimestamp != bfi->hasTimestamp) { |
276 cout << "*** Feature " << fno << " differs in presence of timestamp (" << afi->hasTimestamp << " vs " << bfi->hasTimestamp << ")" << endl; | 305 cout << "*** Feature " << fno << " differs in presence of timestamp (" << afi->hasTimestamp << " vs " << bfi->hasTimestamp << ")" << endl; |
277 } | 306 } |
278 if (afi->hasTimestamp && (afi->timestamp != bfi->timestamp)) { | 307 if (afi->hasTimestamp && (afi->timestamp != bfi->timestamp)) { |
279 cout << "*** Feature " << fno << " differs in timestamp (" << afi->timestamp << " vs " << bfi->timestamp << " )" << endl; | 308 cout << "*** Feature " << fno << " differs in timestamp (" << afi->timestamp << " vs " << bfi->timestamp << " )" << endl; |
284 if (afi->hasDuration && (afi->duration != bfi->duration)) { | 313 if (afi->hasDuration && (afi->duration != bfi->duration)) { |
285 cout << "*** Feature " << fno << " differs in duration (" << afi->duration << " vs " << bfi->duration << " )" << endl; | 314 cout << "*** Feature " << fno << " differs in duration (" << afi->duration << " vs " << bfi->duration << " )" << endl; |
286 } | 315 } |
287 if (afi->label != bfi->label) { | 316 if (afi->label != bfi->label) { |
288 cout << "*** Feature " << fno << " differs in label" << endl; | 317 cout << "*** Feature " << fno << " differs in label" << endl; |
318 } | |
319 if (afi->values.size() != bfi->values.size()) { | |
320 cout << "*** Feature " << fno << " differs in number of values (" << afi->values.size() << " vs " << bfi->values.size() << ")" << endl; | |
289 } | 321 } |
290 if (differInValues) { | 322 if (differInValues) { |
291 cout << "*** Feature " << fno << " differs in values" << endl; | 323 cout << "*** Feature " << fno << " differs in values" << endl; |
292 } | 324 } |
293 cout << " First output:" << endl; | 325 cout << " First output:" << endl; |
294 dumpFeature(*afi, differInValues); | 326 dumpFeature(*afi, differInValues); |
295 cout << " Second output:" << endl; | 327 cout << " Second output:" << endl; |
296 dumpFeature(*bfi, differInValues); | 328 dumpFeature(*bfi, differInValues, &(*afi)); |
297 } | 329 } |
298 ++diffcount; | 330 ++diffcount; |
299 } | 331 } |
300 ++fno; | 332 ++fno; |
301 ++afi; | 333 ++afi; |