! * \brief ColumnTest::testFormulaCellDefault * Use default value if the index is smaller than zero */
| 1478 | * Use default value if the index is smaller than zero |
| 1479 | */ |
| 1480 | void 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 |
nothing calls this directly
no test coverage detected