##// END OF EJS Templates
Separate the initialization of the properties of the graph of the update of the units of the graph....
Separate the initialization of the properties of the graph of the update of the units of the graph. The initialization of the properties is carried out when adding a variable in the graph, the update of the units is carried out when loading the data of this variable

File last commit:

r709:8d80a1dd4059
r1308:41b7c6aab8be
Show More
TestStringUtils.cpp
50 lines | 1.7 KiB | text/x-c | CppLexer
#include <Common/StringUtils.h>
#include <QObject>
#include <QtTest>
class TestStringUtils : public QObject {
Q_OBJECT
private slots:
void testUniqueName_data();
void testUniqueName();
};
void TestStringUtils::testUniqueName_data()
{
// ////////////// //
// Test structure //
// ////////////// //
QTest::addColumn<QString>("defaultName");
QTest::addColumn<std::vector<QString> >("forbiddenNames");
QTest::addColumn<QString>("expectedName");
// ////////// //
// Test cases //
// ////////// //
QTest::newRow("uniqueName") << "FGM" << std::vector<QString>{"FGM2"} << "FGM";
QTest::newRow("uniqueName2") << "FGM2" << std::vector<QString>{"FGM", "FGM1", "FGM2"} << "FGM3";
QTest::newRow("uniqueName3") << "FGM1" << std::vector<QString>{"FGM1"} << "FGM";
QTest::newRow("uniqueName4") << "FGM" << std::vector<QString>{"FGM"} << "FGM1";
QTest::newRow("uniqueName5") << "FGM" << std::vector<QString>{"FGM", "FGM1", "FGM3"} << "FGM2";
QTest::newRow("uniqueName6") << "FGM" << std::vector<QString>{"A", "B", "C"} << "FGM";
QTest::newRow("uniqueName7") << "FGM" << std::vector<QString>{"fGm", "FGm1", "Fgm2"} << "FGM3";
QTest::newRow("uniqueName8") << "" << std::vector<QString>{"A", "B", "C"} << "1";
QTest::newRow("uniqueName9") << "24" << std::vector<QString>{"A", "B", "C"} << "1";
}
void TestStringUtils::testUniqueName()
{
QFETCH(QString, defaultName);
QFETCH(std::vector<QString>, forbiddenNames);
QFETCH(QString, expectedName);
auto result = StringUtils::uniqueName(defaultName, forbiddenNames);
QCOMPARE(result, expectedName);
}
QTEST_MAIN(TestStringUtils)
#include "TestStringUtils.moc"