Commit 66b3528d authored by Thiago Santini's avatar Thiago Santini

Adds test for data vs header delimiters

parent 4202906e
......@@ -48,6 +48,9 @@ MainWindow::MainWindow(QWidget* parent)
*/
volatile QList<QCameraInfo> tmp = QCameraInfo::availableCameras();
Q_UNUSED(tmp);
checkDelimitiers<EyeData>();
checkDelimitiers<FieldData>();
checkDelimitiers<DataTuple>();
gPerformanceMonitor.setFrameDrop(true);
......
......@@ -14,7 +14,7 @@ public:
, showGazeEstimationVisualization(false)
{
}
explicit DataTuple(Timestamp timestamp, EyeData lEye, EyeData rEye, FieldData field)
DataTuple(Timestamp timestamp, EyeData lEye, EyeData rEye, FieldData field)
: timestamp(timestamp)
, lEye(lEye)
, rEye(rEye)
......@@ -31,7 +31,7 @@ public:
{
return journalField(QStringLiteral("sync.timestamp")) % FieldData().header(QStringLiteral("field.")) % EyeData().header(QStringLiteral("left.")) % EyeData().header(QStringLiteral("right."));
}
QString toQString()
QString toQString() const
{
return journalField(timestamp) % field.toQString() % lEye.toQString() % rEye.toQString();
}
......
......@@ -66,10 +66,10 @@ public:
str.append(journalField(undistorted));
str.append(journalField(width));
str.append(journalField(height));
for (unsigned int i = 0; i < markers.size(); i++)
str.append(markers[i].str());
str.append(Token::Delimiter);
str.append(journalField(processingTimestamp));
}
};
Q_DECLARE_METATYPE(FieldData)
......
......@@ -3,6 +3,7 @@
#include <atomic>
#include <iostream>
#include <typeinfo>
#include <QCameraViewfinderSettings>
#include <QDateTime>
......@@ -54,6 +55,17 @@ inline QString journalField<float>(const float& v)
return journalField(static_cast<double>(v));
}
template <typename T>
inline void checkDelimitiers()
{
int dSize = T().toQString().split(Token::Delimiter).size();
int hSize = T().header().split(Token::Delimiter).size();
if (dSize != hSize) {
QString err = QString("%1: Data delimiters (%2) don't match header delimiters (%3)").arg(typeid(T).name()).arg(dSize).arg(hSize);
qFatal(err.toStdString().c_str());
}
}
/*
* Utility functions
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment