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

Method testReadContinuousFixedWithIndexTimestamp

tests/livedata/LiveDataTest.cpp:517–611  ·  view source on GitHub ↗

! * same as testReadContinuousFixed00 but with additional index and timestamp columns */

Source from the content-addressed store, hash-verified

515 * same as testReadContinuousFixed00 but with additional index and timestamp columns
516 */
517void LiveDataTest::testReadContinuousFixedWithIndexTimestamp() {
518 // create a temp file and write some data into it
519 QTemporaryFile tempFile;
520 if (!tempFile.open())
521 QFAIL("failed to create the temp file for writing");
522
523 QFile file(tempFile.fileName());
524 if (!file.open(QIODevice::ReadWrite | QIODevice::Truncate | QIODevice::Text))
525 QFAIL("failed to open the temp file for writing");
526
527 file.write("1,2\n3,4\n");
528 file.flush();
529
530 // initialize the live data source
531 LiveDataSource dataSource(QStringLiteral("test"), false);
532 dataSource.setSourceType(LiveDataSource::SourceType::FileOrPipe);
533 dataSource.setFileType(AbstractFileFilter::FileType::Ascii);
534 dataSource.setFileName(file.fileName());
535 dataSource.setReadingType(LiveDataSource::ReadingType::ContinuousFixed);
536 dataSource.setSampleSize(100); // big number of samples, more then the new data has, meaning we read all new data
537 dataSource.setUpdateType(LiveDataSource::UpdateType::NewData);
538
539 // initialize the ASCII filter
540 auto* filter = new AsciiFilter();
541 auto properties = filter->defaultProperties();
542 properties.headerEnabled = false;
543 properties.intAsDouble = false;
544 properties.columnNamesRaw = QStringLiteral("x, y");
545 properties.columnModesString = QStringLiteral("Int, Int");
546 properties.automaticSeparatorDetection = false;
547 properties.separator = QStringLiteral(",");
548 properties.createIndex = true;
549 properties.createTimestamp = true;
550 QCOMPARE(filter->initialize(properties), AsciiFilter::Status::Success);
551 dataSource.setFilter(filter);
552
553 // read the data and perform checks, after the initial read all data is read
554 dataSource.read();
555
556 QCOMPARE(dataSource.columnCount(), 4);
557 QCOMPARE(dataSource.rowCount(), 2);
558
559 QCOMPARE(dataSource.column(0)->columnMode(), AbstractColumn::ColumnMode::BigInt);
560 QCOMPARE(dataSource.column(1)->columnMode(), AbstractColumn::ColumnMode::DateTime);
561 QCOMPARE(dataSource.column(2)->columnMode(), AbstractColumn::ColumnMode::Integer);
562 QCOMPARE(dataSource.column(3)->columnMode(), AbstractColumn::ColumnMode::Integer);
563
564 QCOMPARE(dataSource.column(0)->bigIntAt(0), 1);
565 QCOMPARE(dataSource.column(1)->dateTimeAt(0).isValid(), true);
566 QCOMPARE(dataSource.column(2)->integerAt(0), 1);
567 QCOMPARE(dataSource.column(3)->integerAt(0), 2);
568
569 QCOMPARE(dataSource.column(0)->bigIntAt(1), 2);
570 QCOMPARE(dataSource.column(1)->dateTimeAt(1).isValid(), true);
571 QCOMPARE(dataSource.column(2)->integerAt(1), 3);
572 QCOMPARE(dataSource.column(3)->integerAt(1), 4);
573
574// currently fails on Windows (waitForSignal()?)

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