Fix duplicate main() linker error in tests
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
- Merged test_mainwindow.cpp tests into test_main.cpp to have single main() - Removed test_mainwindow.cpp from CMakeLists.txt test executable - Qt test executables should have only one main() via QTEST_MAIN() Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Entire-Checkpoint: 0f6858921c53
This commit is contained in:
3 files changed
+36
-50
No files matched your search
@@ -61,7 +61,6 @@ enable_testing()
|
|||||||
# Add test executable
|
# Add test executable
|
||||||
add_executable(Qt6MigratedBenchmarkTest
|
add_executable(Qt6MigratedBenchmarkTest
|
||||||
tests/test_main.cpp
|
tests/test_main.cpp
|
||||||
tests/test_mainwindow.cpp
|
|
||||||
MainWindow.h
|
MainWindow.h
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
class TestMainWindow : public QObject
|
class TestMainWindow : public QObject
|
||||||
@@ -9,6 +11,10 @@ class TestMainWindow : public QObject
|
|||||||
void testValidateInputInvalid();
|
void testValidateInputInvalid();
|
||||||
void testValidateInputEmpty();
|
void testValidateInputEmpty();
|
||||||
void testValidateInputMixedCase();
|
void testValidateInputMixedCase();
|
||||||
|
void testMainWindowCreation();
|
||||||
|
void testWindowTitle();
|
||||||
|
void testValidateInputMethod();
|
||||||
|
void testGetScreenInfo();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestMainWindow::testValidateInputValid()
|
void TestMainWindow::testValidateInputValid()
|
||||||
@@ -47,6 +53,36 @@ void TestMainWindow::testValidateInputMixedCase()
|
|||||||
QVERIFY(pattern.match("aBcDeF999").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)
|
QTEST_MAIN(TestMainWindow)
|
||||||
|
|
||||||
#include "test_main.moc"
|
#include "test_main.moc"
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#include "MainWindow.h"
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QtTest/QtTest>
|
|
||||||
|
|
||||||
class TestMainWindowWidget : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void testMainWindowCreation();
|
|
||||||
void testWindowTitle();
|
|
||||||
void testValidateInputMethod();
|
|
||||||
void testGetScreenInfo();
|
|
||||||
};
|
|
||||||
|
|
||||||
void TestMainWindowWidget::testMainWindowCreation()
|
|
||||||
{
|
|
||||||
MainWindow window;
|
|
||||||
QVERIFY(!window.windowTitle().isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestMainWindowWidget::testWindowTitle()
|
|
||||||
{
|
|
||||||
MainWindow window;
|
|
||||||
QCOMPARE(window.windowTitle(), QStringLiteral("Qt6 Legacy Migration Benchmark"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestMainWindowWidget::testValidateInputMethod()
|
|
||||||
{
|
|
||||||
MainWindow window;
|
|
||||||
|
|
||||||
QVERIFY(window.validateInput(QStringLiteral("Test123")));
|
|
||||||
QVERIFY(window.validateInput(QStringLiteral("abc456")));
|
|
||||||
QVERIFY(!window.validateInput(QStringLiteral("123Test")));
|
|
||||||
QVERIFY(!window.validateInput(QStringLiteral("")));
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestMainWindowWidget::testGetScreenInfo()
|
|
||||||
{
|
|
||||||
MainWindow window;
|
|
||||||
QString info = window.getScreenInfo();
|
|
||||||
QVERIFY(!info.isEmpty());
|
|
||||||
QVERIFY(info.contains(QStringLiteral("Screen:")));
|
|
||||||
}
|
|
||||||
|
|
||||||
QTEST_MAIN(TestMainWindowWidget)
|
|
||||||
|
|
||||||
#include "test_mainwindow.moc"
|
|
||||||
Reference in new issue
Block a user