| 3471 | } |
| 3472 | |
| 3473 | void 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 | |
| 3517 | QTEST_MAIN(SpreadsheetTest) |
nothing calls this directly
no test coverage detected