Mercurial > hg > svcore
comparison data/fileio/test/CSVReaderTest.h @ 1872:566476eeeb80 csv-import-headers
Support headers in actual import step, + test
author | Chris Cannam |
---|---|
date | Thu, 18 Jun 2020 11:55:28 +0100 |
parents | 2654bf447a84 |
children | 1d44fdc8196c |
comparison
equal
deleted
inserted
replaced
1871:bed42ce4d3ab | 1872:566476eeeb80 |
---|---|
79 QCOMPARE(actual->getAllEvents().size(), 5); | 79 QCOMPARE(actual->getAllEvents().size(), 5); |
80 //!!! + the actual contents | 80 //!!! + the actual contents |
81 delete model; | 81 delete model; |
82 } | 82 } |
83 | 83 |
84 void modelType1DSamplesWithHeader() { | |
85 Model *model = nullptr; | |
86 loadFrom("model-type-1d-samples-header.csv", model); | |
87 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | |
88 QVERIFY(actual); | |
89 QCOMPARE(actual->getAllEvents().size(), 5); | |
90 //!!! + the actual contents | |
91 delete model; | |
92 } | |
93 | |
84 void modelType1DSeconds() { | 94 void modelType1DSeconds() { |
85 Model *model = nullptr; | 95 Model *model = nullptr; |
86 loadFrom("model-type-1d-seconds.csv", model); | 96 loadFrom("model-type-1d-seconds.csv", model); |
87 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 97 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
88 QVERIFY(actual); | 98 QVERIFY(actual); |
89 QCOMPARE(actual->getAllEvents().size(), 5); | 99 QCOMPARE(actual->getAllEvents().size(), 5); |
90 delete model; | 100 delete model; |
91 } | 101 } |
92 | 102 |
103 void modelType1DSecondsWithHeader() { | |
104 Model *model = nullptr; | |
105 loadFrom("model-type-1d-seconds-header.csv", model); | |
106 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | |
107 QVERIFY(actual); | |
108 QCOMPARE(actual->getAllEvents().size(), 5); | |
109 delete model; | |
110 } | |
111 | |
93 void modelType2DDurationSamples() { | 112 void modelType2DDurationSamples() { |
94 Model *model = nullptr; | 113 Model *model = nullptr; |
95 loadFrom("model-type-2d-duration-samples.csv", model); | 114 loadFrom("model-type-2d-duration-samples.csv", model); |
96 auto actual = qobject_cast<RegionModel *>(model); | 115 auto actual = qobject_cast<RegionModel *>(model); |
97 QVERIFY(actual); | 116 QVERIFY(actual); |
98 QCOMPARE(actual->getAllEvents().size(), 5); | 117 QCOMPARE(actual->getAllEvents().size(), 5); |
99 delete model; | 118 delete model; |
100 } | 119 } |
120 | |
121 void modelType2DDurationSamplesWithHeader() { | |
122 Model *model = nullptr; | |
123 loadFrom("model-type-2d-duration-samples-header.csv", model); | |
124 auto actual = qobject_cast<RegionModel *>(model); | |
125 QVERIFY(actual); | |
126 QCOMPARE(actual->getAllEvents().size(), 5); | |
127 delete model; | |
128 } | |
101 | 129 |
102 void modelType2DDurationSeconds() { | 130 void modelType2DDurationSeconds() { |
103 Model *model = nullptr; | 131 Model *model = nullptr; |
104 loadFrom("model-type-2d-duration-seconds.csv", model); | 132 loadFrom("model-type-2d-duration-seconds.csv", model); |
105 auto actual = qobject_cast<RegionModel *>(model); | 133 auto actual = qobject_cast<RegionModel *>(model); |
106 QVERIFY(actual); | 134 QVERIFY(actual); |
107 QCOMPARE(actual->getAllEvents().size(), 5); | 135 QCOMPARE(actual->getAllEvents().size(), 5); |
108 delete model; | 136 delete model; |
109 } | 137 } |
110 | 138 |
139 void modelType2DDurationSecondsWithHeader() { | |
140 Model *model = nullptr; | |
141 loadFrom("model-type-2d-duration-seconds-header.csv", model); | |
142 auto actual = qobject_cast<RegionModel *>(model); | |
143 QVERIFY(actual); | |
144 QCOMPARE(actual->getAllEvents().size(), 5); | |
145 delete model; | |
146 } | |
147 | |
111 void badNegativeDuration() { | 148 void badNegativeDuration() { |
112 Model *model = nullptr; | 149 Model *model = nullptr; |
113 loadFrom("bad-negative-duration.csv", model); | 150 loadFrom("bad-negative-duration.csv", model); |
114 auto actual = qobject_cast<RegionModel *>(model); | 151 auto actual = qobject_cast<RegionModel *>(model); |
115 QVERIFY(actual); | 152 QVERIFY(actual); |
125 QVERIFY(actual); | 162 QVERIFY(actual); |
126 QCOMPARE(actual->getAllEvents().size(), 5); | 163 QCOMPARE(actual->getAllEvents().size(), 5); |
127 delete model; | 164 delete model; |
128 } | 165 } |
129 | 166 |
167 void modelType2DEndTimeSamplesWithHeader() { | |
168 Model *model = nullptr; | |
169 loadFrom("model-type-2d-endtime-samples-header.csv", model); | |
170 auto actual = qobject_cast<RegionModel *>(model); | |
171 QVERIFY(actual); | |
172 QCOMPARE(actual->getAllEvents().size(), 5); | |
173 delete model; | |
174 } | |
175 | |
130 void modelType2DEndTimeSeconds() { | 176 void modelType2DEndTimeSeconds() { |
131 Model *model = nullptr; | 177 Model *model = nullptr; |
132 loadFrom("model-type-2d-endtime-seconds.csv", model); | 178 loadFrom("model-type-2d-endtime-seconds.csv", model); |
133 auto actual = qobject_cast<RegionModel *>(model); | 179 auto actual = qobject_cast<RegionModel *>(model); |
134 QVERIFY(actual); | 180 QVERIFY(actual); |
135 QCOMPARE(actual->getAllEvents().size(), 5); | 181 QCOMPARE(actual->getAllEvents().size(), 5); |
136 delete model; | 182 delete model; |
137 } | 183 } |
138 | 184 |
185 void modelType2DEndTimeSecondsWithHeader() { | |
186 Model *model = nullptr; | |
187 loadFrom("model-type-2d-endtime-seconds-header.csv", model); | |
188 auto actual = qobject_cast<RegionModel *>(model); | |
189 QVERIFY(actual); | |
190 QCOMPARE(actual->getAllEvents().size(), 5); | |
191 delete model; | |
192 } | |
193 | |
139 void modelType2DImplicit() { | 194 void modelType2DImplicit() { |
140 Model *model = nullptr; | 195 Model *model = nullptr; |
141 loadFrom("model-type-2d-implicit.csv", model); | 196 loadFrom("model-type-2d-implicit.csv", model); |
142 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 197 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
143 QVERIFY(actual); | 198 QVERIFY(actual); |
144 QCOMPARE(actual->getAllEvents().size(), 5); | 199 QCOMPARE(actual->getAllEvents().size(), 5); |
145 delete model; | 200 delete model; |
146 } | 201 } |
147 | 202 |
203 void modelType2DImplicitWithHeader() { | |
204 Model *model = nullptr; | |
205 loadFrom("model-type-2d-implicit-header.csv", model); | |
206 auto actual = qobject_cast<SparseTimeValueModel *>(model); | |
207 QVERIFY(actual); | |
208 QCOMPARE(actual->getAllEvents().size(), 5); | |
209 delete model; | |
210 } | |
211 | |
148 void modelType2DSamples() { | 212 void modelType2DSamples() { |
149 Model *model = nullptr; | 213 Model *model = nullptr; |
150 loadFrom("model-type-2d-samples.csv", model); | 214 loadFrom("model-type-2d-samples.csv", model); |
151 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 215 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
152 QVERIFY(actual); | 216 QVERIFY(actual); |
153 QCOMPARE(actual->getAllEvents().size(), 5); | 217 QCOMPARE(actual->getAllEvents().size(), 5); |
154 delete model; | 218 delete model; |
155 } | 219 } |
156 | 220 |
221 void modelType2DSamplesWithHeader() { | |
222 Model *model = nullptr; | |
223 loadFrom("model-type-2d-samples-header.csv", model); | |
224 auto actual = qobject_cast<SparseTimeValueModel *>(model); | |
225 QVERIFY(actual); | |
226 QCOMPARE(actual->getAllEvents().size(), 5); | |
227 delete model; | |
228 } | |
229 | |
157 void modelType2DSeconds() { | 230 void modelType2DSeconds() { |
158 Model *model = nullptr; | 231 Model *model = nullptr; |
159 loadFrom("model-type-2d-seconds.csv", model); | 232 loadFrom("model-type-2d-seconds.csv", model); |
160 auto actual = qobject_cast<SparseTimeValueModel *>(model); | 233 auto actual = qobject_cast<SparseTimeValueModel *>(model); |
161 QVERIFY(actual); | 234 QVERIFY(actual); |
162 QCOMPARE(actual->getAllEvents().size(), 5); | 235 QCOMPARE(actual->getAllEvents().size(), 5); |
163 delete model; | 236 delete model; |
164 } | 237 } |
165 | 238 |
239 void modelType2DSecondsWithHeader() { | |
240 Model *model = nullptr; | |
241 loadFrom("model-type-2d-seconds-header.csv", model); | |
242 auto actual = qobject_cast<SparseTimeValueModel *>(model); | |
243 QVERIFY(actual); | |
244 QCOMPARE(actual->getAllEvents().size(), 5); | |
245 delete model; | |
246 } | |
247 | |
166 void modelType3DImplicit() { | 248 void modelType3DImplicit() { |
167 Model *model = nullptr; | 249 Model *model = nullptr; |
168 loadFrom("model-type-3d-implicit.csv", model); | 250 loadFrom("model-type-3d-implicit.csv", model); |
169 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | 251 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); |
170 QVERIFY(actual); | 252 QVERIFY(actual); |
171 QCOMPARE(actual->getWidth(), 6); | 253 QCOMPARE(actual->getWidth(), 6); |
172 QCOMPARE(actual->getHeight(), 6); | 254 QCOMPARE(actual->getHeight(), 6); |
173 delete model; | 255 delete model; |
174 } | 256 } |
175 | 257 |
258 void modelType3DImplicitWithHeader() { | |
259 Model *model = nullptr; | |
260 loadFrom("model-type-3d-implicit-header.csv", model); | |
261 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | |
262 QVERIFY(actual); | |
263 QCOMPARE(actual->getWidth(), 6); | |
264 QCOMPARE(actual->getHeight(), 6); | |
265 delete model; | |
266 } | |
267 | |
176 void modelType3DSamples() { | 268 void modelType3DSamples() { |
177 Model *model = nullptr; | 269 Model *model = nullptr; |
178 loadFrom("model-type-3d-samples.csv", model); | 270 loadFrom("model-type-3d-samples.csv", model); |
179 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | 271 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); |
180 QVERIFY(actual); | 272 QVERIFY(actual); |
181 QCOMPARE(actual->getWidth(), 6); | 273 QCOMPARE(actual->getWidth(), 6); |
182 QCOMPARE(actual->getHeight(), 6); | 274 QCOMPARE(actual->getHeight(), 6); |
183 delete model; | 275 delete model; |
184 } | 276 } |
185 | 277 |
278 void modelType3DSamplesWithHeader() { | |
279 Model *model = nullptr; | |
280 loadFrom("model-type-3d-samples-header.csv", model); | |
281 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | |
282 QVERIFY(actual); | |
283 QCOMPARE(actual->getWidth(), 6); | |
284 QCOMPARE(actual->getHeight(), 6); | |
285 delete model; | |
286 } | |
287 | |
186 void modelType3DSeconds() { | 288 void modelType3DSeconds() { |
187 Model *model = nullptr; | 289 Model *model = nullptr; |
188 loadFrom("model-type-3d-seconds.csv", model); | 290 loadFrom("model-type-3d-seconds.csv", model); |
189 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | 291 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); |
190 QVERIFY(actual); | 292 QVERIFY(actual); |
191 QCOMPARE(actual->getWidth(), 6); | 293 QCOMPARE(actual->getWidth(), 6); |
192 QCOMPARE(actual->getHeight(), 6); | 294 QCOMPARE(actual->getHeight(), 6); |
193 delete model; | 295 delete model; |
194 } | 296 } |
195 | 297 |
298 void modelType3DSecondsWithHeader() { | |
299 Model *model = nullptr; | |
300 loadFrom("model-type-3d-seconds-header.csv", model); | |
301 auto actual = qobject_cast<EditableDenseThreeDimensionalModel *>(model); | |
302 QVERIFY(actual); | |
303 QCOMPARE(actual->getWidth(), 6); | |
304 QCOMPARE(actual->getHeight(), 6); | |
305 delete model; | |
306 } | |
307 | |
196 void withBlankLines1D() { | 308 void withBlankLines1D() { |
197 Model *model = nullptr; | 309 Model *model = nullptr; |
198 loadFrom("with-blank-lines-1d.csv", model); | 310 loadFrom("with-blank-lines-1d.csv", model); |
199 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); | 311 auto actual = qobject_cast<SparseOneDimensionalModel *>(model); |
200 QVERIFY(actual); | 312 QVERIFY(actual); |