Results 1 to 6 of 6

Thread: QTest

  1. #1
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTest

    Some info about this mm... module/class/lib =) will be great!

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

  3. #3
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTest

    already read it =) something not troll docs! anyway thanks.

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

    Default Re: QTest

    What's wrong with that?

  5. #5
    Join Date
    May 2007
    Posts
    46
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTest

    Qt Code:
    1. /****************************************************************************
    2.  **
    3.  ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
    4.  **
    5.  ** This file is part of the example classes of the Qt Toolkit.
    6.  **
    7.  ** This file may be used under the terms of the GNU General Public
    8.  ** License version 2.0 as published by the Free Software Foundation
    9.  ** and appearing in the file LICENSE.GPL included in the packaging of
    10.  ** this file. Please review the following information to ensure GNU
    11.  ** General Public Licensing requirements will be met:
    12.  ** http://www.trolltech.com/products/qt/opensource.html
    13.  **
    14.  ** If you are unsure which license is appropriate for your use, please
    15.  ** review the following information:
    16.  ** http://www.trolltech.com/products/qt/licensing.html or contact the
    17.  ** sales department at sales@trolltech.com.
    18.  **
    19.  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
    20.  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
    21.  **
    22.  ****************************************************************************/
    23.  
    24. #include <QtTest/QtTest>
    25.  
    26. class TestQString: public QObject
    27. {
    28. Q_OBJECT
    29.  
    30. private slots:
    31. void toUpper_data();
    32. void toUpper();
    33. };
    34.  
    35. void TestQString::toUpper_data()
    36. {
    37. QTest::addColumn<QString>("string");
    38. QTest::addColumn<QString>("result");
    39.  
    40. QTest::newRow("all lower") << "hello" << "HELLO";
    41. QTest::newRow("mixed") << "Hello" << "HELLO";
    42. QTest::newRow("all upper") << "HELLO" << "HELLO";
    43. }
    44.  
    45. void TestQString::toUpper()
    46. {
    47. QFETCH(QString, string);
    48. QFETCH(QString, result);
    49.  
    50. QCOMPARE(string.toUpper(), result);
    51. }
    52.  
    53. QTEST_MAIN(TestQString)
    54. #include "testqstring.moc"
    To copy to clipboard, switch view to plain text mode 

    explain please how works this _data() function, when it is called, how and what args this get from console (parameters).

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

    Default Re: QTest

    Slots with _data suffix are called by the test framework to enable data driven tests. It's all explained in the docs, you know...

    http://doc.trolltech.com/latest/qtestlib-tutorial2.html
    http://doc.trolltech.com/latest/qtes...line-arguments

Similar Threads

  1. QTest
    By Mordicus in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2006, 10:35
  2. QTest Unit Testing
    By bothapn in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2006, 22:11

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.