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

Method testSortSingleText1

tests/spreadsheet/SpreadsheetTest.cpp:662–688  ·  view source on GitHub ↗

* check sorting single column of text with empty entries ascending */

Source from the content-addressed store, hash-verified

660 * check sorting single column of text with empty entries ascending
661 */
662void SpreadsheetTest::testSortSingleText1() {
663 const QVector<QString> xData{QStringLiteral("ben"),
664 QStringLiteral("amy"),
665 QStringLiteral("eddy"),
666 QString(),
667 QStringLiteral("carl"),
668 QStringLiteral("dan")};
669
670 Spreadsheet sheet(QStringLiteral("test"), false);
671 sheet.setColumnCount(1);
672 sheet.setRowCount(8);
673 auto* col = sheet.column(0);
674 col->setColumnMode(AbstractColumn::ColumnMode::Text);
675 col->replaceTexts(0, xData);
676
677 // sort
678 sheet.sortColumns(nullptr, {col}, true);
679
680 // values
681 QCOMPARE(col->textAt(0), QLatin1String("amy"));
682 QCOMPARE(col->textAt(1), QLatin1String("ben"));
683 QCOMPARE(col->textAt(2), QLatin1String("carl"));
684 QCOMPARE(col->textAt(3), QLatin1String("dan"));
685 QCOMPARE(col->textAt(4), QLatin1String("eddy"));
686 QCOMPARE(col->textAt(5), QString());
687 QCOMPARE(col->textAt(6), QString());
688}
689
690/*
691 * check sorting single column of text with empty entries descending

Callers

nothing calls this directly

Calls 8

QStringClass · 0.50
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceTextsMethod · 0.45
sortColumnsMethod · 0.45
textAtMethod · 0.45

Tested by

no test coverage detected