- Format MainWindow.cpp, MainWindow.h, main.cpp - Format test files (test_main.cpp, test_mainwindow.cpp) - Fixes Jenkins clang-format policy check Entire-Checkpoint: ea47c089bf3a Signed-off-by: twi-devel <torsten.wierschin@life-maps.com>
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include <QtTest/QtTest>
|
|
|
|
class TestMainWindow : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void testValidateInputValid();
|
|
void testValidateInputInvalid();
|
|
void testValidateInputEmpty();
|
|
void testValidateInputMixedCase();
|
|
};
|
|
|
|
void TestMainWindow::testValidateInputValid()
|
|
{
|
|
// Test valid input patterns
|
|
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
|
|
|
|
QVERIFY(pattern.match("Test123").hasMatch());
|
|
QVERIFY(pattern.match("abc456").hasMatch());
|
|
QVERIFY(pattern.match("ABC789").hasMatch());
|
|
}
|
|
|
|
void TestMainWindow::testValidateInputInvalid()
|
|
{
|
|
// Test invalid input patterns
|
|
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
|
|
|
|
QVERIFY(!pattern.match("123Test").hasMatch());
|
|
QVERIFY(!pattern.match("Test").hasMatch());
|
|
QVERIFY(!pattern.match("123").hasMatch());
|
|
QVERIFY(!pattern.match("Test123ABC").hasMatch());
|
|
QVERIFY(!pattern.match("Test-123").hasMatch());
|
|
}
|
|
|
|
void TestMainWindow::testValidateInputEmpty()
|
|
{
|
|
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
|
|
QVERIFY(!pattern.match("").hasMatch());
|
|
}
|
|
|
|
void TestMainWindow::testValidateInputMixedCase()
|
|
{
|
|
QRegularExpression pattern(R"(^[A-Za-z]+\d+$)");
|
|
|
|
QVERIFY(pattern.match("TeSt123").hasMatch());
|
|
QVERIFY(pattern.match("aBcDeF999").hasMatch());
|
|
}
|
|
|
|
QTEST_MAIN(TestMainWindow)
|
|
|
|
#include "test_main.moc" |