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

Method testCreateIndexAndTimestamp

tests/import_export/ASCII/AsciiFilterTest.cpp:1333–1379  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1331}
1332
1333void AsciiFilterTest::testCreateIndexAndTimestamp() {
1334 Spreadsheet spreadsheet(QStringLiteral("test"), false);
1335 AsciiFilter filter;
1336 auto p = filter.properties();
1337 p.automaticSeparatorDetection = true;
1338 p.separator = QStringLiteral(",");
1339 p.headerEnabled = false;
1340 p.headerLine = 1;
1341 p.intAsDouble = false;
1342 p.createIndex = true;
1343 p.createTimestamp = true;
1344 p.columnNamesRaw = QStringLiteral("x,y,z");
1345 filter.setProperties(p);
1346
1347 QString savePath;
1348 SAVE_FILE("testfile", numeric_data);
1349 filter.readDataFromFile(savePath, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
1350
1351 // no ranges specified, all rows and columns have to be read plus the additional column for the index
1352 QCOMPARE(spreadsheet.rowCount(), 5);
1353 QCOMPARE(spreadsheet.columnCount(), 5);
1354
1355 QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::ColumnMode::BigInt);
1356 QCOMPARE(spreadsheet.column(1)->columnMode(), AbstractColumn::ColumnMode::DateTime);
1357 QCOMPARE(spreadsheet.column(2)->columnMode(), AbstractColumn::ColumnMode::Double);
1358 QCOMPARE(spreadsheet.column(3)->columnMode(), AbstractColumn::ColumnMode::Double);
1359 QCOMPARE(spreadsheet.column(4)->columnMode(), AbstractColumn::ColumnMode::Double);
1360
1361 // check the values for the first line
1362 QCOMPARE(spreadsheet.column(0)->bigIntAt(0), 1);
1363 QCOMPARE(spreadsheet.column(2)->valueAt(0), 1.716299);
1364 QCOMPARE(spreadsheet.column(3)->valueAt(0), -0.485527);
1365 QCOMPARE(spreadsheet.column(4)->valueAt(0), -0.288690);
1366
1367 // Index
1368 QCOMPARE(spreadsheet.column(0)->bigIntAt(1), 2);
1369 QCOMPARE(spreadsheet.column(0)->bigIntAt(2), 3);
1370 QCOMPARE(spreadsheet.column(0)->bigIntAt(3), 4);
1371 QCOMPARE(spreadsheet.column(0)->bigIntAt(4), 5);
1372
1373 // Timestamp
1374 // TODO: maybe checking also the value that they are monotonic increasing?
1375 QVERIFY(spreadsheet.column(1)->dateTimeAt(1).isValid());
1376 QVERIFY(spreadsheet.column(1)->dateTimeAt(2).isValid());
1377 QVERIFY(spreadsheet.column(1)->dateTimeAt(3).isValid());
1378 QVERIFY(spreadsheet.column(1)->dateTimeAt(4).isValid());
1379}
1380
1381void AsciiFilterTest::testStartColumn() {
1382 Spreadsheet spreadsheet(QStringLiteral("test"), false);

Callers

nothing calls this directly

Calls 11

setPropertiesMethod · 0.80
propertiesMethod · 0.45
readDataFromFileMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
columnModeMethod · 0.45
columnMethod · 0.45
bigIntAtMethod · 0.45
valueAtMethod · 0.45
isValidMethod · 0.45
dateTimeAtMethod · 0.45

Tested by

no test coverage detected