MCPcopy Create free account
hub / github.com/KDE/labplot / testReadContinuousFixedWithIndex

Method testReadContinuousFixedWithIndex

tests/livedata/LiveDataTest.cpp:337–422  ·  view source on GitHub ↗

! * same as testReadContinuousFixed00 but with an additional index column */

Source from the content-addressed store, hash-verified

335 * same as testReadContinuousFixed00 but with an additional index column
336 */
337void LiveDataTest::testReadContinuousFixedWithIndex() {
338 // create a temp file and write some data into it
339 QTemporaryFile tempFile;
340 if (!tempFile.open())
341 QFAIL("failed to create the temp file for writing");
342
343 QFile file(tempFile.fileName());
344 if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text))
345 QFAIL("failed to open the temp file for writing");
346
347 file.write("1,2\n3,4\n");
348 file.flush();
349
350 // initialize the live data source
351 LiveDataSource dataSource(QStringLiteral("test"), false);
352 dataSource.setSourceType(LiveDataSource::SourceType::FileOrPipe);
353 dataSource.setFileType(AbstractFileFilter::FileType::Ascii);
354 dataSource.setFileName(file.fileName());
355 dataSource.setReadingType(LiveDataSource::ReadingType::ContinuousFixed);
356 dataSource.setSampleSize(100); // big number of samples, more then the new data has, meaning we read all new data
357 dataSource.setUpdateType(LiveDataSource::UpdateType::NewData);
358
359 // initialize the ASCII filter
360 auto* filter = new AsciiFilter();
361 auto properties = filter->defaultProperties();
362 properties.headerEnabled = false;
363 properties.intAsDouble = false;
364 properties.columnNamesRaw = QStringLiteral("x, y");
365 properties.columnModesString = QStringLiteral("Int, Int");
366 properties.automaticSeparatorDetection = false;
367 properties.separator = QStringLiteral(",");
368 properties.createIndex = true;
369 QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success);
370 dataSource.setFilter(filter);
371
372 // read the data and perform checks, after the initial read all data is read
373 dataSource.read();
374
375 QCOMPARE(dataSource.columnCount(), 3);
376 QCOMPARE(dataSource.rowCount(), 2);
377
378 QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::BigInt);
379 QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::Integer);
380 QCOMPARE(dataSource.column(2)->columnMode(), AbstractColumn::ColumnMode::Integer);
381
382 QCOMPARE(dataSource.column(0)->bigIntAt(0), 1);
383 QCOMPARE(dataSource.column(1)->integerAt(0), 1);
384 QCOMPARE(dataSource.column(2)->integerAt(0), 2);
385
386 QCOMPARE(dataSource.column(0)->bigIntAt(1), 2);
387 QCOMPARE(dataSource.column(1)->integerAt(1), 3);
388 QCOMPARE(dataSource.column(2)->integerAt(1), 4);
389
390// currently fails on Windows (waitForSignal()?)
391#ifdef HAVE_WINDOWS
392 return;
393#endif
394 // write out more data to the file

Callers

nothing calls this directly

Calls 15

setSourceTypeMethod · 0.80
setFileTypeMethod · 0.80
defaultPropertiesMethod · 0.80
openMethod · 0.45
fileNameMethod · 0.45
writeMethod · 0.45
setFileNameMethod · 0.45
setReadingTypeMethod · 0.45
setSampleSizeMethod · 0.45
setUpdateTypeMethod · 0.45
initializeMethod · 0.45
setFilterMethod · 0.45

Tested by

no test coverage detected