summaryrefslogtreecommitdiffstats
path: root/src/test/signalpathtest.h
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2015-04-19 20:16:52 -0400
committerOwen Williams <owilliams@mixxx.org>2015-04-19 20:16:52 -0400
commitf18efc27ae3dd63b0f6205152ab61aacafb2abcd (patch)
treef7ebd3949045566b46a6488946fe417ccecd42bb /src/test/signalpathtest.h
parent4d474eeb4e1cf2e820f47a3805fd62536a0079b6 (diff)
Make testing properly stereo-based
Diffstat (limited to 'src/test/signalpathtest.h')
-rw-r--r--src/test/signalpathtest.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/test/signalpathtest.h b/src/test/signalpathtest.h
index 099c15a53f..4ee2fbad08 100644
--- a/src/test/signalpathtest.h
+++ b/src/test/signalpathtest.h
@@ -120,7 +120,8 @@ class SignalPathTest : public MixxxTest {
// directory. Remove the ".actual" extension to create the file the test
// will compare against. On the next run, the test should pass.
// Use scripts/AudioPlot.py to look at the golden file and make sure it
- // looks correct.
+ // looks correct. Each line of the generated file contains the left sample
+ // followed by the right sample.
void assertBufferMatchesGolden(CSAMPLE* pBuffer, const int iBufferSize,
QString golden_title, const double delta=.0001) {
QFile f(QDir::currentPath() + "/src/test/golden_buffers/" + golden_title);
@@ -131,16 +132,27 @@ class SignalPathTest : public MixxxTest {
if (f.open(QFile::ReadOnly | QFile::Text)) {
QTextStream in(&f);
// Note: We will only compare as many values as there are in the golden file.
- for (; i < iBufferSize && !in.atEnd(); ++i) {
- QString line = in.readLine();
+ for (; i < iBufferSize && !in.atEnd(); i += 2) {
+ QStringList line = in.readLine().split(',');
+ if (line.length() != 2) {
+ qWarning() << "Unexpected line length in golden file";
+ pass = false;
+ break;
+ }
bool ok = false;
- double gold_value = line.toDouble(&ok);
+ double gold_value0 = line[0].toDouble(&ok);
+ double gold_value1 = line[1].toDouble(&ok);
EXPECT_TRUE(ok);
- if (fabs(gold_value - pBuffer[i]) > delta) {
+ if (fabs(gold_value0 - pBuffer[i]) > delta) {
qWarning() << "Golden check failed at index" << i;
pass = false;
break;
}
+ if (fabs(gold_value1 - pBuffer[i + 1]) > delta) {
+ qWarning() << "Golden check failed at index" << i + 1;
+ pass = false;
+ break;
+ }
}
}
// Fail if either we didn't pass, or the comparison file was empty.
@@ -152,8 +164,8 @@ class SignalPathTest : public MixxxTest {
QFile actual(QDir::currentPath() + "/src/test/golden_buffers/" + fname_actual);
ASSERT_TRUE(actual.open(QFile::WriteOnly | QFile::Text));
QTextStream out(&actual);
- for (int i = 0; i < iBufferSize; ++i) {
- out << QString("%1\n").arg(pBuffer[i]);
+ for (int i = 0; i < iBufferSize; i += 2) {
+ out << QString("%1,%2\n").arg(pBuffer[i]).arg(pBuffer[i + 1]);
}
actual.close();
EXPECT_TRUE(false);