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

Method testClearColumns

tests/spreadsheet/SpreadsheetTest.cpp:3473–3515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3471}
3472
3473void SpreadsheetTest::testClearColumns() {
3474 Project project;
3475 auto* sheet = new Spreadsheet(QStringLiteral("test"), false);
3476 project.addChild(sheet);
3477
3478 new SpreadsheetModel(sheet);
3479
3480 sheet->setColumnCount(3);
3481 QCOMPARE(sheet->columnCount(), 3);
3482 sheet->setRowCount(10);
3483
3484 auto* c0 = sheet->column(0);
3485 auto* c1 = sheet->column(1);
3486 auto* c2 = sheet->column(2);
3487
3488 for (int i = 0; i < 10; i++) {
3489 c0->setValueAt(i, i);
3490 c1->setValueAt(i, 2. * i + 3.);
3491 c2->setValueAt(i, pow(i, 3.));
3492 }
3493
3494 for (int i = 0; i < 10; i++) {
3495 QCOMPARE(c0->valueAt(i), i);
3496 QCOMPARE(c1->valueAt(i), 2. * i + 3.);
3497 QCOMPARE(c2->valueAt(i), pow(i, 3.));
3498 }
3499
3500 sheet->clear({c0, c2});
3501
3502 for (int i = 0; i < 10; i++) {
3503 QCOMPARE(c0->valueAt(i), NAN);
3504 QCOMPARE(c1->valueAt(i), 2. * i + 3.);
3505 QCOMPARE(c2->valueAt(i), NAN);
3506 }
3507
3508 sheet->undoStack()->undo();
3509
3510 for (int i = 0; i < 10; i++) {
3511 QCOMPARE(c0->valueAt(i), i);
3512 QCOMPARE(c1->valueAt(i), 2. * i + 3.);
3513 QCOMPARE(c2->valueAt(i), pow(i, 3.));
3514 }
3515}
3516
3517QTEST_MAIN(SpreadsheetTest)

Callers

nothing calls this directly

Calls 10

addChildMethod · 0.45
setColumnCountMethod · 0.45
columnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setValueAtMethod · 0.45
valueAtMethod · 0.45
clearMethod · 0.45
undoMethod · 0.45
undoStackMethod · 0.45

Tested by

no test coverage detected