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

Method testFormulaAutoResizeEnabled

tests/backend/Column/ColumnTest.cpp:641–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639}
640
641void ColumnTest::testFormulaAutoResizeEnabled() {
642 Column sourceColumn1(QStringLiteral("source1"), Column::ColumnMode::Integer);
643 sourceColumn1.setIntegers({1, 2, 3});
644
645 Column sourceColumn2(QStringLiteral("source2"), Column::ColumnMode::Integer);
646 sourceColumn2.setIntegers({1, 2, 3});
647
648 // spreadsheet needs to be created since the resize of the column is happening via the resize of the spreadsheet
649 Spreadsheet targetSpreadsheet(QStringLiteral("target"));
650 targetSpreadsheet.setColumnCount(1);
651 targetSpreadsheet.setRowCount(1);
652 Column* targetColumn = targetSpreadsheet.column(0);
653
654 // evaluatue x+y
655 targetColumn->setColumnMode(AbstractColumn::ColumnMode::Double);
656 targetColumn->setFormula(QStringLiteral("x+y"),
657 QStringList{QStringLiteral("x"), QStringLiteral("y")},
658 QVector<Column*>({&sourceColumn1, &sourceColumn2}),
659 false /* autoUpdate */,
660 true /* autoResize */);
661 targetColumn->updateFormula();
662
663 // check the generated values in the target column which should have been resized
664 QCOMPARE(targetColumn->rowCount(), 3);
665 QCOMPARE(targetColumn->valueAt(0), 2);
666 QCOMPARE(targetColumn->valueAt(1), 4);
667 QCOMPARE(targetColumn->valueAt(2), 6);
668}
669
670void ColumnTest::testFormulaAutoResizeDisabled() {
671 Column sourceColumn1(QStringLiteral("source1"), Column::ColumnMode::Integer);

Callers

nothing calls this directly

Calls 9

setIntegersMethod · 0.80
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
setFormulaMethod · 0.45
updateFormulaMethod · 0.45
rowCountMethod · 0.45
valueAtMethod · 0.45

Tested by

no test coverage detected