| 583 | } |
| 584 | |
| 585 | void ColumnTest::testFormulaAutoUpdateEnabled() { |
| 586 | Column sourceColumn(QStringLiteral("source"), Column::ColumnMode::Integer); |
| 587 | sourceColumn.setIntegers({1, 2, 3}); |
| 588 | |
| 589 | Column targetColumn(QStringLiteral("target"), Column::ColumnMode::Integer); |
| 590 | targetColumn.setIntegers({3, 2, 1}); |
| 591 | |
| 592 | // evaluatue 2*x and check the generated values in the target column |
| 593 | targetColumn.setColumnMode(AbstractColumn::ColumnMode::Double); // should happen automatically in Column::setFormula() |
| 594 | targetColumn.setFormula(QStringLiteral("2*x"), |
| 595 | QStringList{QStringLiteral("x")}, |
| 596 | QVector<Column*>({&sourceColumn}), |
| 597 | true /* autoUpdate */, |
| 598 | false /* autoResize */); |
| 599 | targetColumn.updateFormula(); |
| 600 | QCOMPARE(targetColumn.rowCount(), 3); |
| 601 | QCOMPARE(targetColumn.valueAt(0), 2); |
| 602 | QCOMPARE(targetColumn.valueAt(1), 4); |
| 603 | QCOMPARE(targetColumn.valueAt(2), 6); |
| 604 | |
| 605 | // modify value in the source column and check the target column again which should be updated |
| 606 | sourceColumn.setIntegers({3, 2, 1}); |
| 607 | QCOMPARE(targetColumn.rowCount(), 3); |
| 608 | QCOMPARE(targetColumn.valueAt(0), 6); |
| 609 | QCOMPARE(targetColumn.valueAt(1), 4); |
| 610 | QCOMPARE(targetColumn.valueAt(2), 2); |
| 611 | } |
| 612 | |
| 613 | void ColumnTest::testFormulaAutoUpdateDisabled() { |
| 614 | Column sourceColumn(QStringLiteral("source"), Column::ColumnMode::Integer); |
nothing calls this directly
no test coverage detected