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

Method testSortNumeric1

tests/spreadsheet/SpreadsheetTest.cpp:783–811  ·  view source on GitHub ↗

multiple column * check sorting double values with NaN ascending as leading column */

Source from the content-addressed store, hash-verified

781 * check sorting double values with NaN ascending as leading column
782 */
783void SpreadsheetTest::testSortNumeric1() {
784 const QVector<double> xData{0.5, -0.2, GSL_NAN, 2.0, -1.0};
785 const QVector<int> yData{1, 2, 3, 4, 5, 6};
786
787 Spreadsheet sheet(QStringLiteral("test"), false);
788 sheet.setColumnCount(2);
789 sheet.setRowCount(10);
790 auto* col0{sheet.column(0)};
791 auto* col1{sheet.column(1)};
792 col0->replaceValues(0, xData);
793 col1->setColumnMode(AbstractColumn::ColumnMode::Integer);
794 col1->replaceInteger(0, yData);
795
796 // sort
797 sheet.sortColumns(col0, {col0, col1}, true);
798
799 // values
800 QCOMPARE(col0->valueAt(0), -1.0);
801 QCOMPARE(col0->valueAt(1), -0.2);
802 QCOMPARE(col0->valueAt(2), 0.5);
803 QCOMPARE(col0->valueAt(3), 2.0);
804 // QCOMPARE(col0->valueAt(4), GSL_NAN);
805 QCOMPARE(col1->integerAt(0), 5);
806 QCOMPARE(col1->integerAt(1), 2);
807 QCOMPARE(col1->integerAt(2), 1);
808 QCOMPARE(col1->integerAt(3), 4);
809 QCOMPARE(col1->integerAt(4), 3);
810 QCOMPARE(col1->integerAt(5), 6);
811}
812
813/*
814 * check sorting double values with NaN descending 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