Results 1 to 5 of 5

Thread: Custom QT test macros

  1. #1
    Join Date
    Apr 2011
    Posts
    132
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Custom QT test macros

    Hi

    I have to write few macros which I have, but are very simple, eg.

    Qt Code:
    1. void Macros::Example( cond )
    2. {
    3. if ( cond )
    4. QFAIL("some message");
    5. }
    To copy to clipboard, switch view to plain text mode 

    This works fine but it does not show me a message line and file where it failed. It shows me a file and the line of QFAIL("some message");.

    I would like to write a macro like QVERIFY to show me where it failed. I tried digging in libraries, all functions like QTestLog are not available from the include.

    Possible?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Custom QT test macros

    How about using QVERIFY2() ?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2011
    Posts
    132
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Re: Custom QT test macros

    Its not the point of displaying message. It is a point of heaviest and diff job for the macro. One of them I need to verify number of records in database. This code I would need to repeat all over the places in function cases in all test classes.

    eg.

    CONFIRM_RECORDS(1)
    Having a job inside the macro in static class function instead, like Macros::ConfirmRecords(1) and use QVERIFY2 for verification would give me a line and file name of QVERIFY2 failure inside the Macros::ConfirmRecords(1) function, and not actually of Macros::ConfirmRecords(1) function failure, and no way to find a place of failure if Macros::ConfirmRecords(1) is added in 10 other places in one case function.

    That's why I need builds own macros, but so far they show me the same like using static function.

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Custom QT test macros

    To be honest I have no idea what you are saying. If you are building your custom reporting macros then why do you want to use the built-in ones? Can't you do it like so?

    Qt Code:
    1. QVERIFY2(countRecords(obj) == 1), ...);
    To copy to clipboard, switch view to plain text mode 

    or if you want to keep your syntax:

    Qt Code:
    1. QVERIFY2(Macros::ConfirmRecords(1) == true, ...);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    migel (26th January 2012)

  6. #5
    Join Date
    Apr 2011
    Posts
    132
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    14

    Default Re: Custom QT test macros

    pff, that would work - thanks

Similar Threads

  1. Qt creator macros
    By ahmdsd_ostora in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2010, 07:23
  2. Keyboard macros in Qt Creator?
    By PUK_999 in forum Qt Tools
    Replies: 1
    Last Post: 11th August 2009, 22:43
  3. macros in QT
    By Noxxik in forum Qt Programming
    Replies: 5
    Last Post: 20th March 2009, 10:09
  4. win32 platform macros?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 20:02
  5. Qt Source Macros
    By cwalsh in forum Qt Programming
    Replies: 1
    Last Post: 8th January 2006, 18:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.