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

QVERIFY / QCOMPARE macros could use an upgrade

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • None
    • Testing: qtestlib
    • None

    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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              Unassigned Unassigned
              paeglis Gatis Paeglis
              Votes:
              4 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes