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

Method testSortNumeric2

tests/spreadsheet/SpreadsheetTest.cpp:816–844  ·  view source on GitHub ↗

* check sorting double values with NaN descending as leading column */

Source from the content-addressed store, hash-verified

814 * check sorting double values with NaN descending as leading column
815 */
816void SpreadsheetTest::testSortNumeric2() {
817 const QVector<double> xData{0.5, -0.2, GSL_NAN, 2.0, -1.0};
818 const QVector<int> yData{1, 2, 3, 4, 5, 6, 7};
819
820 Spreadsheet sheet(QStringLiteral("test"), false);
821 sheet.setColumnCount(2);
822 sheet.setRowCount(10);
823 auto* col0{sheet.column(0)};
824 auto* col1{sheet.column(1)};
825 col0->replaceValues(0, xData);
826 col1->setColumnMode(AbstractColumn::ColumnMode::Integer);
827 col1->replaceInteger(0, yData);
828
829 // sort
830 sheet.sortColumns(col0, {col0, col1}, false);
831
832 // values
833 QCOMPARE(col0->valueAt(0), 2.0);
834 QCOMPARE(col0->valueAt(1), 0.5);
835 QCOMPARE(col0->valueAt(2), -0.2);
836 QCOMPARE(col0->valueAt(3), -1.0);
837 QCOMPARE(col1->integerAt(0), 4);
838 QCOMPARE(col1->integerAt(1), 1);
839 QCOMPARE(col1->integerAt(2), 2);
840 QCOMPARE(col1->integerAt(3), 5);
841 QCOMPARE(col1->integerAt(4), 3);
842 QCOMPARE(col1->integerAt(5), 6);
843 QCOMPARE(col1->integerAt(6), 7);
844}
845
846/*
847 * check sorting integer values with empty entries ascending as leading column

Callers

nothing calls this directly

Calls 9

setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
replaceValuesMethod · 0.45
setColumnModeMethod · 0.45
replaceIntegerMethod · 0.45
sortColumnsMethod · 0.45
valueAtMethod · 0.45
integerAtMethod · 0.45

Tested by

no test coverage detected