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

Method testDateTime00

tests/import_export/ASCII/AsciiFilterTest.cpp:2242–2282  ·  view source on GitHub ↗

! * read data containing only two characters for the year - 'yy'. The default year in * QDateTime is 1900 . When reading such two-characters DateTime values we want * to have the current centure after the import. */

Source from the content-addressed store, hash-verified

2240 * to have the current centure after the import.
2241 */
2242void AsciiFilterTest::testDateTime00() {
2243 Spreadsheet spreadsheet(QStringLiteral("test"), false);
2244
2245 AsciiFilter filter;
2246 auto p = filter.properties();
2247 p.automaticSeparatorDetection = false;
2248 p.separator = QStringLiteral(",");
2249 p.headerEnabled = true;
2250 p.headerLine = 1;
2251 p.intAsDouble = false;
2252 p.dateTimeFormat = QLatin1String("dd/MM/yy hh:mm:ss");
2253 p.baseYear = 2000;
2254 filter.setProperties(p);
2255
2256 QString savePath;
2257 SAVE_FILE("testfile", dateTime01Content);
2258 filter.readDataFromFile(savePath, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
2259
2260 // spreadsheet size
2261 QCOMPARE(spreadsheet.columnCount(), 2);
2262 QCOMPARE(spreadsheet.rowCount(), 2);
2263
2264 // column names
2265 QCOMPARE(spreadsheet.column(0)->name(), QLatin1String("Date"));
2266 QCOMPARE(spreadsheet.column(1)->name(), QLatin1String("Water Pressure"));
2267
2268 // data types
2269 QCOMPARE(spreadsheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime);
2270 QCOMPARE(spreadsheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Double);
2271
2272 // values
2273 auto value = QDateTime::fromString(QLatin1String("01/01/2019 00:00:00"), QLatin1String("dd/MM/yyyy hh:mm:ss"));
2274 value.setTimeSpec(Qt::UTC);
2275 QCOMPARE(spreadsheet.column(0)->dateTimeAt(0), value);
2276 QCOMPARE(spreadsheet.column(1)->valueAt(0), 14.7982);
2277
2278 value = QDateTime::fromString(QLatin1String("01/01/2019 00:30:00"), QLatin1String("dd/MM/yyyy hh:mm:ss"));
2279 value.setTimeSpec(Qt::UTC);
2280 QCOMPARE(spreadsheet.column(0)->dateTimeAt(1), value);
2281 QCOMPARE(spreadsheet.column(1)->valueAt(1), 14.8026);
2282}
2283
2284void AsciiFilterTest::testDateTimeDefaultDateTimeFormat() {
2285 const QStringList content = {

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected