##// END OF EJS Templates
Tests 2-dim ctor
Alexandre Leroux -
r520:fe4a55706bcb
parent child
Show More
@@ -11,6 +11,10 private slots:
11 void testDataByComponentIndex_data();
11 void testDataByComponentIndex_data();
12 void testDataByComponentIndex();
12 void testDataByComponentIndex();
13
13
14 /// Tests @sa ArrayData ctor
15 void testCtor_data();
16 void testCtor();
17
14 /// Tests @sa ArrayData::add()
18 /// Tests @sa ArrayData::add()
15 void testAdd_data();
19 void testAdd_data();
16 void testAdd();
20 void testAdd();
@@ -56,6 +60,44 void TestTwoDimArrayData::testDataByComponentIndex()
56 QVERIFY(arrayData.data(componentIndex) == expectedData);
60 QVERIFY(arrayData.data(componentIndex) == expectedData);
57 }
61 }
58
62
63 void TestTwoDimArrayData::testCtor_data()
64 {
65 // Test structure
66 QTest::addColumn<DataContainer>("inputData"); // array data's input
67 QTest::addColumn<bool>("success"); // array data has been successfully constructed
68 QTest::addColumn<DataContainer>("expectedData"); // expected array data (when success)
69
70 // Test cases
71 QTest::newRow("validInput")
72 << DataContainer{{1., 2., 3., 4., 5.}, {6., 7., 8., 9., 10.}, {11., 12., 13., 14., 15.}}
73 << true
74 << DataContainer{{1., 2., 3., 4., 5.}, {6., 7., 8., 9., 10.}, {11., 12., 13., 14., 15.}};
75 QTest::newRow("malformedInput (components of the array data haven't the same size")
76 << DataContainer{{1., 2., 3., 4., 5.}, {6., 7., 8.}, {11., 12.}} << true
77 << DataContainer{{}, {}, {}};
78 QTest::newRow("invalidInput (less than tow components")
79 << DataContainer{{1., 2., 3., 4., 5.}} << false << DataContainer{{}, {}, {}};
80 }
81
82 void TestTwoDimArrayData::testCtor()
83 {
84 QFETCH(DataContainer, inputData);
85 QFETCH(bool, success);
86
87 if (success) {
88 QFETCH(DataContainer, expectedData);
89
90 ArrayData<2> arrayData{inputData};
91
92 for (auto i = 0; i < expectedData.size(); ++i) {
93 QVERIFY(arrayData.data(i) == expectedData.at(i));
94 }
95 }
96 else {
97 QVERIFY_EXCEPTION_THROWN(ArrayData<2> arrayData{inputData}, std::invalid_argument);
98 }
99 }
100
59 void TestTwoDimArrayData::testAdd_data()
101 void TestTwoDimArrayData::testAdd_data()
60 {
102 {
61 // Test structure
103 // Test structure
General Comments 0
You need to be logged in to leave comments. Login now