From 766a3018077c53ba293df77ed97b4d96d84931f6 2017-08-08 07:43:09 From: Alexandre Leroux Date: 2017-08-08 07:43:09 Subject: [PATCH] Tests specific methods of 1-dim array data --- diff --git a/core/tests/Data/TestOneDimArrayData.cpp b/core/tests/Data/TestOneDimArrayData.cpp index 6bda43e..675e263 100644 --- a/core/tests/Data/TestOneDimArrayData.cpp +++ b/core/tests/Data/TestOneDimArrayData.cpp @@ -5,6 +5,10 @@ class TestOneDimArrayData : public QObject { Q_OBJECT private slots: + /// Tests @sa ArrayData::data() + void testData_data(); + void testData(); + /// Tests @sa ArrayData::data(int componentIndex) void testDataByComponentIndex_data(); void testDataByComponentIndex(); @@ -13,6 +17,10 @@ private slots: void testAdd_data(); void testAdd(); + /// Tests @sa ArrayData::at(int index) + void testAt_data(); + void testAt(); + /// Tests @sa ArrayData::clear() void testClear_data(); void testClear(); @@ -102,6 +110,37 @@ void TestOneDimArrayData::testAdd() QVERIFY(arrayData.data() == expectedData); } +void TestOneDimArrayData::testAt_data() +{ + // Test structure + QTest::addColumn >("inputData"); // array data's input + QTest::addColumn("index"); // index to retrieve data + QTest::addColumn("expectedData"); // expected data at index + + // Test cases + QTest::newRow("data1") << QVector{1., 2., 3., 4., 5.} << 0 << 1.; + QTest::newRow("data2") << QVector{1., 2., 3., 4., 5.} << 3 << 4.; +} + +void TestOneDimArrayData::testAt() +{ + QFETCH(QVector, inputData); + QFETCH(int, index); + QFETCH(double, expectedData); + + ArrayData<1> arrayData{inputData}; + QVERIFY(arrayData.at(index) == expectedData); +} + +void TestOneDimArrayData::testClear_data() +{ + // Test structure + QTest::addColumn >("inputData"); // array data's input + + // Test cases + QTest::newRow("data1") << QVector{1., 2., 3., 4., 5.}; +} + void TestOneDimArrayData::testClear() { QFETCH(QVector, inputData);