qt-migration-copilot-demo/pipeline/pr-main This commit looks good
- Changed #include from test_main.moc to test_mainwindow.moc - Required for Qt Meta-Object Compiler to process Q_OBJECT macro Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 5ac05d07f260
88 lines
2.2 KiB
C++
88 lines
2.2 KiB
C++
#include "MainWindow.h"
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
class TestMainWindow : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void testValidateInputValid();
|
|
void testValidateInputInvalid();
|
|
void testValidateInputEmpty();
|
|
void testValidateInputMixedCase();
|
|
void testMainWindowCreation();
|
|
void testWindowTitle();
|
|
void testValidateInputMethod();
|
|
void testGetScreenInfo();
|
|
};
|
|
|
|
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());
|
|
}
|
|
|
|
void TestMainWindow::testMainWindowCreation()
|
|
{
|
|
MainWindow window;
|
|
QVERIFY(!window.windowTitle().isEmpty());
|
|
}
|
|
|
|
void TestMainWindow::testWindowTitle()
|
|
{
|
|
MainWindow window;
|
|
QCOMPARE(window.windowTitle(), QStringLiteral("Qt6 Legacy Migration Benchmark"));
|
|
}
|
|
|
|
void TestMainWindow::testValidateInputMethod()
|
|
{
|
|
MainWindow window;
|
|
|
|
QVERIFY(window.validateInput(QStringLiteral("Test123")));
|
|
QVERIFY(window.validateInput(QStringLiteral("abc456")));
|
|
QVERIFY(!window.validateInput(QStringLiteral("123Test")));
|
|
QVERIFY(!window.validateInput(QStringLiteral("")));
|
|
}
|
|
|
|
void TestMainWindow::testGetScreenInfo()
|
|
{
|
|
MainWindow window;
|
|
QString info = window.getScreenInfo();
|
|
QVERIFY(!info.isEmpty());
|
|
QVERIFY(info.contains(QStringLiteral("Screen:")));
|
|
}
|
|
|
|
QTEST_MAIN(TestMainWindow)
|
|
|
|
#include "test_mainwindow.moc" |