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

Method testCopyPasteColumnMode04

tests/spreadsheet/SpreadsheetTest.cpp:203–235  ·  view source on GitHub ↗

! automatically detect the proper format for the datetime columns */

Source from the content-addressed store, hash-verified

201 automatically detect the proper format for the datetime columns
202 */
203void SpreadsheetTest::testCopyPasteColumnMode04() {
204 QLocale::setDefault(QLocale::C); // . as decimal separator
205 Spreadsheet sheet(QStringLiteral("test"), false);
206 sheet.setColumnCount(2);
207 sheet.setRowCount(100);
208
209 const QString str = QStringLiteral(
210 "2020-09-20 11:21:40:849 7.7\n"
211 "2020-09-20 11:21:41:830 4.2");
212
213 QApplication::clipboard()->setText(str);
214
215 SpreadsheetView view(&sheet, false);
216 view.pasteIntoSelection();
217
218 // spreadsheet size
219 QCOMPARE(sheet.columnCount(), 2);
220 QCOMPARE(sheet.rowCount(), 100);
221
222 // column modes
223 QCOMPARE(sheet.column(0)->columnMode(), AbstractColumn::ColumnMode::DateTime);
224 QCOMPARE(sheet.column(1)->columnMode(), AbstractColumn::ColumnMode::Double);
225
226 // values
227 auto* filter = static_cast<DateTime2StringFilter*>(sheet.column(0)->outputFilter());
228 const QString& format = filter->format();
229
230 QCOMPARE(sheet.column(0)->dateTimeAt(0).toString(format), QLatin1String("2020-09-20 11:21:40:849"));
231 QCOMPARE(sheet.column(1)->valueAt(0), 7.7);
232
233 QCOMPARE(sheet.column(0)->dateTimeAt(1).toString(format), QLatin1String("2020-09-20 11:21:41:830"));
234 QCOMPARE(sheet.column(1)->valueAt(1), 4.2);
235}
236
237/*!
238 automatically detect the proper format for the datetime columns, time part only

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