diff --git a/qt6-after/qt6-migrated-benchmark/MainWindow.cpp b/qt6-after/qt6-migrated-benchmark/MainWindow.cpp index cb55ec3..5f0a954 100644 --- a/qt6-after/qt6-migrated-benchmark/MainWindow.cpp +++ b/qt6-after/qt6-migrated-benchmark/MainWindow.cpp @@ -1,16 +1,15 @@ #include "MainWindow.h" + #include "ui_MainWindow.h" #include -#include #include -#include #include +#include +#include -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) - , m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)")) +MainWindow::MainWindow(QWidget* parent) + : QMainWindow(parent), ui(new Ui::MainWindow), m_pattern(QRegularExpression(R"(^[A-Za-z]+\d+$)")) { ui->setupUi(this); @@ -28,15 +27,16 @@ MainWindow::~MainWindow() delete ui; } -bool MainWindow::validateInput(const QString &text) const +bool MainWindow::validateInput(const QString& text) const { return m_pattern.match(text).hasMatch(); } QString MainWindow::getScreenInfo() const { - const QScreen *screen = QApplication::primaryScreen(); - if (!screen) { + const QScreen* screen = QApplication::primaryScreen(); + if (!screen) + { return u"Screen: unavailable"_s; } const QRect geometry = screen->geometry(); @@ -47,9 +47,12 @@ void MainWindow::onValidateClicked() { const QString text = ui->lineEdit->text(); - if (validateInput(text)) { + if (validateInput(text)) + { ui->resultLabel->setText(u"Match"_s); - } else { + } + else + { ui->resultLabel->setText(u"No match"_s); } } diff --git a/qt6-after/qt6-migrated-benchmark/MainWindow.h b/qt6-after/qt6-migrated-benchmark/MainWindow.h index e251caf..6d75f70 100644 --- a/qt6-after/qt6-migrated-benchmark/MainWindow.h +++ b/qt6-after/qt6-migrated-benchmark/MainWindow.h @@ -4,27 +4,30 @@ #include QT_BEGIN_NAMESPACE -namespace Ui { + +namespace Ui +{ class MainWindow; } + QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT -public: - explicit MainWindow(QWidget *parent = nullptr); + public: + explicit MainWindow(QWidget* parent = nullptr); ~MainWindow(); - [[nodiscard]] bool validateInput(const QString &text) const; + [[nodiscard]] bool validateInput(const QString& text) const; [[nodiscard]] QString getScreenInfo() const; -public slots: + public slots: void onValidateClicked(); void onScreenInfoClicked(); -private: - Ui::MainWindow *ui; + private: + Ui::MainWindow* ui; QRegularExpression m_pattern; }; \ No newline at end of file diff --git a/qt6-after/qt6-migrated-benchmark/main.cpp b/qt6-after/qt6-migrated-benchmark/main.cpp index 9a7e594..cffbc19 100644 --- a/qt6-after/qt6-migrated-benchmark/main.cpp +++ b/qt6-after/qt6-migrated-benchmark/main.cpp @@ -1,7 +1,8 @@ -#include #include "MainWindow.h" -int main(int argc, char *argv[]) +#include + +int main(int argc, char* argv[]) { QApplication a(argc, argv); MainWindow w; diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_main.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_main.cpp index 085fafa..4f2c31e 100644 --- a/qt6-after/qt6-migrated-benchmark/tests/test_main.cpp +++ b/qt6-after/qt6-migrated-benchmark/tests/test_main.cpp @@ -4,7 +4,7 @@ class TestMainWindow : public QObject { Q_OBJECT -private slots: + private slots: void testValidateInputValid(); void testValidateInputInvalid(); void testValidateInputEmpty(); @@ -15,7 +15,7 @@ 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()); @@ -25,7 +25,7 @@ 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()); @@ -42,7 +42,7 @@ void TestMainWindow::testValidateInputEmpty() void TestMainWindow::testValidateInputMixedCase() { QRegularExpression pattern(R"(^[A-Za-z]+\d+$)"); - + QVERIFY(pattern.match("TeSt123").hasMatch()); QVERIFY(pattern.match("aBcDeF999").hasMatch()); } diff --git a/qt6-after/qt6-migrated-benchmark/tests/test_mainwindow.cpp b/qt6-after/qt6-migrated-benchmark/tests/test_mainwindow.cpp index c498bf6..92010a0 100644 --- a/qt6-after/qt6-migrated-benchmark/tests/test_mainwindow.cpp +++ b/qt6-after/qt6-migrated-benchmark/tests/test_mainwindow.cpp @@ -1,12 +1,13 @@ -#include -#include #include "MainWindow.h" +#include +#include + class TestMainWindowWidget : public QObject { Q_OBJECT -private slots: + private slots: void testMainWindowCreation(); void testWindowTitle(); void testValidateInputMethod(); @@ -28,7 +29,7 @@ void TestMainWindowWidget::testWindowTitle() void TestMainWindowWidget::testValidateInputMethod() { MainWindow window; - + QVERIFY(window.validateInput(u"Test123"_s)); QVERIFY(window.validateInput(u"abc456"_s)); QVERIFY(!window.validateInput(u"123Test"_s));