##// END OF EJS Templates
Tests clear() and size() methods
Alexandre Leroux -
r517:16e3b7f34e6f
parent child
Show More
@@ -13,6 +13,14 private slots:
13 13 void testAdd_data();
14 14 void testAdd();
15 15
16 /// Tests @sa ArrayData::clear()
17 void testClear_data();
18 void testClear();
19
20 /// Tests @sa ArrayData::size()
21 void testSize_data();
22 void testSize();
23
16 24 };
17 25
18 26 void TestOneDimArrayData::testDataByComponentIndex_data()
@@ -71,5 +79,33 void TestOneDimArrayData::testAdd()
71 79 QVERIFY(arrayData.data() == expectedData);
72 80 }
73 81
82 void TestOneDimArrayData::testClear()
83 {
84 QFETCH(QVector<double>, inputData);
85
86 ArrayData<1> arrayData{inputData};
87 arrayData.clear();
88 QVERIFY(arrayData.data() == QVector<double>{});
89 }
90
91 void TestOneDimArrayData::testSize_data()
92 {
93 // Test structure
94 QTest::addColumn<QVector<double> >("inputData"); // array data's input
95 QTest::addColumn<int>("expectedSize"); // expected array data size
96
97 // Test cases
98 QTest::newRow("data1") << QVector<double>{1., 2., 3., 4., 5.} << 5;
99 }
100
101 void TestOneDimArrayData::testSize()
102 {
103 QFETCH(QVector<double>, inputData);
104 QFETCH(int, expectedSize);
105
106 ArrayData<1> arrayData{inputData};
107 QVERIFY(arrayData.size() == expectedSize);
108 }
109
74 110 QTEST_MAIN(TestOneDimArrayData)
75 111 #include "TestOneDimArrayData.moc"
@@ -15,6 +15,14 private slots:
15 15 void testAdd_data();
16 16 void testAdd();
17 17
18 /// Tests @sa ArrayData::clear()
19 void testClear_data();
20 void testClear();
21
22 /// Tests @sa ArrayData::size()
23 void testSize_data();
24 void testSize();
25
18 26 };
19 27
20 28 void TestTwoDimArrayData::testDataByComponentIndex_data()
@@ -89,5 +97,50 void TestTwoDimArrayData::testAdd()
89 97 }
90 98 }
91 99
100 void TestTwoDimArrayData::testClear_data()
101 {
102 // Test structure
103 QTest::addColumn<DataContainer>("inputData"); // array data's input
104
105 // Test cases
106 QTest::newRow("data1") << DataContainer{
107 {1., 2., 3., 4., 5.}, {6., 7., 8., 9., 10.}, {11., 12., 13., 14., 15.}};
108 }
109
110 void TestTwoDimArrayData::testClear()
111 {
112 QFETCH(DataContainer, inputData);
113
114 ArrayData<2> arrayData{inputData};
115 arrayData.clear();
116
117 for (auto i = 0; i < inputData.size(); ++i) {
118 QVERIFY(arrayData.data(i) == QVector<double>{});
119 }
120 }
121
122 void TestTwoDimArrayData::testSize_data()
123 {
124 // Test structure
125 QTest::addColumn<QVector<QVector<double> > >("inputData"); // array data's input
126 QTest::addColumn<int>("expectedSize"); // expected array data size
127
128 // Test cases
129 QTest::newRow("data1") << DataContainer{{1., 2., 3., 4., 5.}, {6., 7., 8., 9., 10.}} << 5;
130 QTest::newRow("data2") << DataContainer{{1., 2., 3., 4., 5.},
131 {6., 7., 8., 9., 10.},
132 {11., 12., 13., 14., 15.}}
133 << 5;
134 }
135
136 void TestTwoDimArrayData::testSize()
137 {
138 QFETCH(DataContainer, inputData);
139 QFETCH(int, expectedSize);
140
141 ArrayData<2> arrayData{inputData};
142 QVERIFY(arrayData.size() == expectedSize);
143 }
144
92 145 QTEST_MAIN(TestTwoDimArrayData)
93 146 #include "TestTwoDimArrayData.moc"
General Comments 0
You need to be logged in to leave comments. Login now