Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-62354

QVERIFY / QCOMPARE macros could use an upgrade

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Testing: qtestlib
    • Labels:
      None
    • Technical Risk:
      Normal

      Description

      QVERIFY and QCOMPARE macros can only be used in functions returning void; In more complex test cases a test might want to use these macros also in non void functions.

      See for example this test: https://codereview.qt-project.org/#/c/153336/22/tests/auto/qx11info/tst_qx11info.cpp

      It would be nice if we could set arbitrary "exit functions" for macros , e.g. "return;" (default), "return false", "close()" (as in QWindow);

      This missing feature becomes more important now with an introduction of lambdas in C++: In the same example code, instead of writing :

      obj->m_foundFirstEventAgain = true;
      

      It would be cleaner just to add QFAIL macro there, that calls QWindow::close();

      This would need to be looked at properly, maybe there are better alternatives to macros.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-62354
          # Subject Branch Project Status CR V

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                paeglis Gatis Paeglis
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Gerrit Reviews

                  There are no open Gerrit changes