Rename test file to match policy script pattern
qt-migration-copilot-demo/pipeline/pr-main There was a failure building this commit
qt-migration-copilot-demo/pipeline/pr-main There was a failure building this commit
- Rename tests/test_main.cpp to tests/test_mainwindow.cpp - Update CMakeLists.txt to reference new test filename - This ensures policy check script finds matching test for MainWindow.cpp Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: fa1f655c111a
This commit is contained in:
2 files changed
+89
-1
No files matched your search
@@ -60,7 +60,7 @@ enable_testing()
|
|||||||
|
|
||||||
# Add test executable
|
# Add test executable
|
||||||
add_executable(Qt6MigratedBenchmarkTest
|
add_executable(Qt6MigratedBenchmarkTest
|
||||||
tests/test_main.cpp
|
tests/test_mainwindow.cpp
|
||||||
MainWindow.h
|
MainWindow.h
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
#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_main.moc"
|
||||||
Reference in new issue
Block a user