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

Method testCopyPasteColumnMode05

tests/spreadsheet/SpreadsheetTest.cpp:240–272  ·  view source on GitHub ↗

! automatically detect the proper format for the datetime columns, time part only */

Source from the content-addressed store, hash-verified

238 automatically detect the proper format for the datetime columns, time part only
239 */
240void SpreadsheetTest::testCopyPasteColumnMode05() {
241 QLocale::setDefault(QLocale::C); // . as decimal separator
242 Spreadsheet sheet(QStringLiteral("test"), false);
243 sheet.setColumnCount(2);
244 sheet.setRowCount(100);
245
246 const QString str = QStringLiteral(
247 "11:21:40 7.7\n"
248 "11:21:41 4.2");
249
250 QApplication::clipboard()->setText(str);
251
252 SpreadsheetView view(&sheet, false);
253 view.pasteIntoSelection();
254
255 // spreadsheet size
256 QCOMPARE(sheet.columnCount(), 2);
257 QCOMPARE(sheet.rowCount(), 100);
258
259 // column modes
260 QCOMPARE(sheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime);
261 QCOMPARE(sheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Double);
262
263 // values
264 auto* filter = static_cast<DateTime2StringFilter*>(sheet.column(0)->outputFilter());
265 const QString& format = filter->format();
266
267 QCOMPARE(sheet.column(0)->dateTimeAt(0).toString(format), QLatin1String("11:21:40"));
268 QCOMPARE(sheet.column(1)->valueAt(0), 7.7);
269
270 QCOMPARE(sheet.column(0)->dateTimeAt(1).toString(format), QLatin1String("11:21:41"));
271 QCOMPARE(sheet.column(1)->valueAt(1), 4.2);
272}
273
274/*!
275 automatically detect the proper format for the datetime columns having the format "yyyy-MM-dd hh:mm:ss"

Callers

nothing calls this directly

Calls 13

setColumnCountMethod · 0.45
setRowCountMethod · 0.45
setTextMethod · 0.45
pasteIntoSelectionMethod · 0.45
columnCountMethod · 0.45
rowCountMethod · 0.45
columnModeMethod · 0.45
columnMethod · 0.45
outputFilterMethod · 0.45
formatMethod · 0.45
toStringMethod · 0.45
dateTimeAtMethod · 0.45

Tested by

no test coverage detected