##// END OF EJS Templates
Tests get data by index method
Tests get data by index method

File last commit:

r515:6d79c86d7f69
r515:6d79c86d7f69
Show More
TestOneDimArrayData.cpp
40 lines | 1.3 KiB | text/x-c | CppLexer
/ core / tests / Data / TestOneDimArrayData.cpp
Alexandre Leroux
Inits unit tests for 1-dim and 2-dim array data
r514 #include "Data/ArrayData.h"
#include <QObject>
#include <QtTest>
class TestOneDimArrayData : public QObject {
Q_OBJECT
private slots:
Alexandre Leroux
Tests get data by index method
r515 /// Tests @sa ArrayData::data(int componentIndex)
void testDataByComponentIndex_data();
void testDataByComponentIndex();
Alexandre Leroux
Inits unit tests for 1-dim and 2-dim array data
r514 };
Alexandre Leroux
Tests get data by index method
r515 void TestOneDimArrayData::testDataByComponentIndex_data()
{
// Test structure
QTest::addColumn<QVector<double> >("inputData"); // array data's input
QTest::addColumn<int>("componentIndex"); // component index to test
QTest::addColumn<QVector<double> >("expectedData"); // expected data
// Test cases
QTest::newRow("validIndex") << QVector<double>{1., 2., 3., 4., 5.} << 0
<< QVector<double>{1., 2., 3., 4., 5.};
QTest::newRow("invalidIndex1")
<< QVector<double>{1., 2., 3., 4., 5.} << -1 << QVector<double>{};
QTest::newRow("invalidIndex2") << QVector<double>{1., 2., 3., 4., 5.} << 1 << QVector<double>{};
}
void TestOneDimArrayData::testDataByComponentIndex()
{
QFETCH(QVector<double>, inputData);
QFETCH(int, componentIndex);
QFETCH(QVector<double>, expectedData);
ArrayData<1> arrayData{inputData};
QVERIFY(arrayData.data(componentIndex) == expectedData);
}
Alexandre Leroux
Inits unit tests for 1-dim and 2-dim array data
r514 QTEST_MAIN(TestOneDimArrayData)
#include "TestOneDimArrayData.moc"