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

QVERIFY / QCOMPARE macros could use an upgrade

XMLWordPrintable

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

      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.

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

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

              Created:
              Updated:

                There are no open Gerrit changes