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

Method testFormulaAutoUpdateEnabled

tests/backend/Column/ColumnTest.cpp:585–611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585void 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
613void ColumnTest::testFormulaAutoUpdateDisabled() {
614 Column sourceColumn(QStringLiteral("source"), Column::ColumnMode::Integer);

Callers

nothing calls this directly

Calls 6

setIntegersMethod · 0.80
setColumnModeMethod · 0.45
setFormulaMethod · 0.45
updateFormulaMethod · 0.45
rowCountMethod · 0.45
valueAtMethod · 0.45

Tested by

no test coverage detected