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

Method testFormulaCellDefault

tests/backend/Column/ColumnTest.cpp:1480–1497  ·  view source on GitHub ↗

! * \brief ColumnTest::testFormulaCellDefault * Use default value if the index is smaller than zero */

Source from the content-addressed store, hash-verified

1478 * Use default value if the index is smaller than zero
1479 */
1480void ColumnTest::testFormulaCellDefault() {
1481 auto c1 = Column(QStringLiteral("DataColumn"), Column::ColumnMode::Double);
1482 c1.replaceValues(-1, {1., 5., -1.});
1483
1484 auto c2 = Column(QStringLiteral("FormulaColumn"), Column::ColumnMode::Double);
1485 c2.replaceValues(-1, {11., 12., 13., 14., 15., 16., 17.});
1486
1487 c2.setFormula(QStringLiteral("cell_with_default(i - 1; -113; x)"), {QStringLiteral("x")}, QVector<Column*>({&c1}), true);
1488 c2.updateFormula();
1489 QCOMPARE(c2.rowCount(), 7);
1490 VALUES_EQUAL(c2.valueAt(0), -113.);
1491 VALUES_EQUAL(c2.valueAt(1), 1.);
1492 VALUES_EQUAL(c2.valueAt(2), 5.);
1493 VALUES_EQUAL(c2.valueAt(3), NAN); // There are only 3 elements in c1
1494 VALUES_EQUAL(c2.valueAt(4), NAN);
1495 VALUES_EQUAL(c2.valueAt(5), NAN);
1496 VALUES_EQUAL(c2.valueAt(6), NAN);
1497}
1498
1499/*!
1500 * index in cell higher than rownumber

Callers

nothing calls this directly

Calls 6

ColumnClass · 0.50
replaceValuesMethod · 0.45
setFormulaMethod · 0.45
updateFormulaMethod · 0.45
rowCountMethod · 0.45
valueAtMethod · 0.45

Tested by

no test coverage detected