Doc: Make Qt Test snippets compilable
Task-number: QTBUG-81498 Change-Id: I22f07cd539e5e317b6cf15eb369d59915146bd13 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
0c2d6c163f
commit
713cd83200
@ -67,7 +67,7 @@ Q_CORE_EXPORT void QTestPrivate::qSleep(int ms)
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
\snippet code/src_corelib_kernel_qtestsupport_core.cpp 0
|
\snippet code/src_corelib_kernel_qtestsupport_core_snippet.cpp 0
|
||||||
|
|
||||||
The code above will wait for the object to become ready, for a
|
The code above will wait for the object to become ready, for a
|
||||||
maximum of three seconds.
|
maximum of three seconds.
|
||||||
|
@ -48,14 +48,28 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
// dummy
|
||||||
|
class TestGui: public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
void testGui_data();
|
||||||
|
};
|
||||||
|
|
||||||
|
void TestGui::testGui_data()
|
||||||
|
{
|
||||||
|
QWidget *myParent = nullptr;
|
||||||
//! [0]
|
//! [0]
|
||||||
QTestEventList events;
|
QTestEventList events;
|
||||||
events.addKeyClick('a');
|
events.addKeyClick('a');
|
||||||
events.addKeyClick(Qt::Key_Backspace);
|
events.addKeyClick(Qt::Key_Backspace);
|
||||||
events.addDelay(200);
|
events.addDelay(200);
|
||||||
|
|
||||||
QLineEdit *lineEdit = new QLineEdit(myParent);
|
QLineEdit *lineEdit = new QLineEdit(myParent);
|
||||||
...
|
// ...
|
||||||
events.simulate(lineEdit);
|
events.simulate(lineEdit);
|
||||||
events.simulate(lineEdit);
|
events.simulate(lineEdit);
|
||||||
//! [0]
|
//! [0]
|
||||||
|
}
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
#include "src_qtestlib_qtestcase.cpp"
|
||||||
//! [0]
|
//! [0]
|
||||||
class MyFirstTest: public QObject
|
class MyFirstTest: public QObject
|
||||||
{
|
{
|
||||||
@ -95,13 +95,15 @@ void TestQString::toUpper()
|
|||||||
}
|
}
|
||||||
//! [8]
|
//! [8]
|
||||||
|
|
||||||
|
void TestQString::Compare()
|
||||||
|
{
|
||||||
//! [11]
|
//! [11]
|
||||||
QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
|
QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
|
||||||
QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
|
QCOMPARE(QString("Hello").toUpper(), QString("HELLO"));
|
||||||
QCOMPARE(QString("HellO").toUpper(), QString("HELLO"));
|
QCOMPARE(QString("HellO").toUpper(), QString("HELLO"));
|
||||||
QCOMPARE(QString("HELLO").toUpper(), QString("HELLO"));
|
QCOMPARE(QString("HELLO").toUpper(), QString("HELLO"));
|
||||||
//! [11]
|
//! [11]
|
||||||
|
}
|
||||||
|
|
||||||
//! [12]
|
//! [12]
|
||||||
class MyFirstBenchmark: public QObject
|
class MyFirstBenchmark: public QObject
|
||||||
|
@ -47,20 +47,22 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include <QTest>
|
||||||
|
|
||||||
//! [0]
|
//dummy class
|
||||||
|
class tst_Skip
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void test_data();
|
||||||
|
};
|
||||||
|
|
||||||
if ( tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt()<5 )
|
|
||||||
QSKIP( "Test requires MySQL >= 5.0");
|
|
||||||
//! [0]
|
|
||||||
//! [1]
|
|
||||||
void tst_Skip::test_data()
|
void tst_Skip::test_data()
|
||||||
{
|
{
|
||||||
|
//! [1]
|
||||||
QTest::addColumn<bool>("bool");
|
QTest::addColumn<bool>("bool");
|
||||||
QTest::newRow("local 1") << false;
|
QTest::newRow("local 1") << false;
|
||||||
QTest::newRow("local 2") << true;
|
QTest::newRow("local 2") << true;
|
||||||
|
|
||||||
QSKIP("skipping all");
|
QSKIP("skipping all");
|
||||||
}
|
|
||||||
//! [1]
|
//! [1]
|
||||||
void tst_Skip::test_data()
|
}
|
||||||
|
53
src/testlib/doc/snippets/code/doc_src_qtqskip_snippet.cpp
Normal file
53
src/testlib/doc/snippets/code/doc_src_qtqskip_snippet.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the documentation of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** BSD License Usage
|
||||||
|
** Alternatively, you may use this file under the terms of the BSD license
|
||||||
|
** as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||||
|
** contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
//! [0]
|
||||||
|
if (tst_Databases::getMySqlVersion(db).section(QChar('.'), 0, 0).toInt() < 5)
|
||||||
|
QSKIP("Test requires MySQL >= 5.0");
|
||||||
|
//! [0]
|
@ -47,17 +47,27 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include <QtTest>
|
||||||
|
|
||||||
//! [0]
|
// dummy class
|
||||||
MyObject obj;
|
class MyObject
|
||||||
obj.startup();
|
{
|
||||||
QTest::qWaitFor([&]() {
|
public:
|
||||||
return obj.isReady();
|
int isReady();
|
||||||
}, 3000);
|
};
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
// dummy function
|
||||||
|
int myNetworkServerNotResponding()
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MyObject::isReady()
|
||||||
|
{
|
||||||
//! [1]
|
//! [1]
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (myNetworkServerNotResponding() && i++ < 50)
|
while (myNetworkServerNotResponding() && i++ < 50)
|
||||||
QTest::qWait(250);
|
QTest::qWait(250);
|
||||||
//! [1]
|
//! [1]
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the documentation of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** BSD License Usage
|
||||||
|
** Alternatively, you may use this file under the terms of the BSD license
|
||||||
|
** as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||||
|
** contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/! [0]
|
||||||
|
MyObject obj;
|
||||||
|
obj.startup();
|
||||||
|
QTest::qWaitFor([&]() {
|
||||||
|
return obj.isReady();
|
||||||
|
}, 3000);
|
||||||
|
//! [0]
|
@ -47,25 +47,50 @@
|
|||||||
** $QT_END_LICENSE$
|
** $QT_END_LICENSE$
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include <QTest>
|
||||||
|
#include <QSqlDatabase>
|
||||||
|
|
||||||
|
// dummy
|
||||||
|
class TestBenchmark : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private slots:
|
||||||
|
void simple();
|
||||||
|
};
|
||||||
|
|
||||||
|
// dummy
|
||||||
|
class MyTestClass : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void cleanup();
|
||||||
|
void addSingleStringRows();
|
||||||
|
void addMultStringRows();
|
||||||
|
void addDataRow();
|
||||||
|
};
|
||||||
|
// dummy
|
||||||
|
void closeAllDatabases()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestQString : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void toInt_data();
|
||||||
|
void toInt();
|
||||||
|
void toUpper();
|
||||||
|
void Compare();
|
||||||
|
};
|
||||||
|
|
||||||
void wrapInFunction()
|
void wrapInFunction()
|
||||||
{
|
{
|
||||||
|
|
||||||
//! [0]
|
|
||||||
QVERIFY(spy.isValid())
|
|
||||||
//! [0]
|
|
||||||
|
|
||||||
|
|
||||||
//! [1]
|
//! [1]
|
||||||
QVERIFY2(qIsNaN(0.0 / 0.0), "Ill-defined division produced unambiguous result.");
|
QVERIFY2(qIsNaN(0.0 / 0.0), "Ill-defined division produced unambiguous result.");
|
||||||
//! [1]
|
//! [1]
|
||||||
|
|
||||||
|
|
||||||
//! [2]
|
//! [2]
|
||||||
QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
|
QCOMPARE(QString("hello").toUpper(), QString("HELLO"));
|
||||||
//! [2]
|
//! [2]
|
||||||
|
}
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
void TestQString::toInt_data()
|
void TestQString::toInt_data()
|
||||||
@ -79,7 +104,6 @@ void TestQString::toInt_data()
|
|||||||
}
|
}
|
||||||
//! [3]
|
//! [3]
|
||||||
|
|
||||||
|
|
||||||
//! [4]
|
//! [4]
|
||||||
void TestQString::toInt()
|
void TestQString::toInt()
|
||||||
{
|
{
|
||||||
@ -90,109 +114,69 @@ void TestQString::toInt()
|
|||||||
}
|
}
|
||||||
//! [4]
|
//! [4]
|
||||||
|
|
||||||
|
void testInt()
|
||||||
|
{
|
||||||
|
// dummy
|
||||||
|
int i = 0, j = 0;
|
||||||
//! [5]
|
//! [5]
|
||||||
if (sizeof(int) != 4)
|
if (sizeof(int) != 4)
|
||||||
QFAIL("This test has not been ported to this platform yet.");
|
QFAIL("This test has not been ported to this platform yet.");
|
||||||
//! [5]
|
//! [5]
|
||||||
|
|
||||||
|
|
||||||
//! [6]
|
//! [6]
|
||||||
QFETCH(QString, myString);
|
QFETCH(QString, myString);
|
||||||
QCOMPARE(QString("hello").toUpper(), myString);
|
QCOMPARE(QString("hello").toUpper(), myString);
|
||||||
//! [6]
|
//! [6]
|
||||||
|
|
||||||
|
|
||||||
//! [7]
|
//! [7]
|
||||||
QTEST(QString("hello").toUpper(), "myString");
|
QTEST(QString("hello").toUpper(), "myString");
|
||||||
//! [7]
|
//! [7]
|
||||||
|
|
||||||
|
|
||||||
//! [8]
|
//! [8]
|
||||||
if (!QSqlDatabase::drivers().contains("SQLITE"))
|
if (!QSqlDatabase::drivers().contains("SQLITE"))
|
||||||
QSKIP("This test requires the SQLITE database driver");
|
QSKIP("This test requires the SQLITE database driver");
|
||||||
//! [8]
|
//! [8]
|
||||||
|
|
||||||
|
|
||||||
//! [9]
|
//! [9]
|
||||||
QEXPECT_FAIL("", "Will fix in the next release", Continue);
|
QEXPECT_FAIL("", "Will fix in the next release", Continue);
|
||||||
QCOMPARE(i, 42);
|
QCOMPARE(i, 42);
|
||||||
QCOMPARE(j, 43);
|
QCOMPARE(j, 43);
|
||||||
//! [9]
|
//! [9]
|
||||||
|
|
||||||
|
|
||||||
//! [10]
|
//! [10]
|
||||||
QEXPECT_FAIL("data27", "Oh my, this is soooo broken", Abort);
|
QEXPECT_FAIL("data27", "Oh my, this is soooo broken", Abort);
|
||||||
QCOMPARE(i, 42);
|
QCOMPARE(i, 42);
|
||||||
//! [10]
|
//! [10]
|
||||||
|
}
|
||||||
|
|
||||||
//! [11]
|
//! [11]
|
||||||
class TestQString: public QObject { ... };
|
|
||||||
QTEST_MAIN(TestQString)
|
QTEST_MAIN(TestQString)
|
||||||
//! [11]
|
//! [11]
|
||||||
|
|
||||||
|
void testObject()
|
||||||
//! [13]
|
{
|
||||||
QTest::keyClick(myWidget, 'a');
|
class MyTestObject: public QObject
|
||||||
//! [13]
|
{
|
||||||
|
public:
|
||||||
|
void toString();
|
||||||
//! [14]
|
};
|
||||||
QTest::keyClick(myWidget, Qt::Key_Escape);
|
|
||||||
|
|
||||||
QTest::keyClick(myWidget, Qt::Key_Escape, Qt::ShiftModifier, 200);
|
|
||||||
//! [14]
|
|
||||||
|
|
||||||
|
|
||||||
//! [15]
|
|
||||||
QTest::keyClicks(myWidget, "hello world");
|
|
||||||
//! [15]
|
|
||||||
|
|
||||||
|
|
||||||
//! [16]
|
|
||||||
namespace QTest {
|
|
||||||
template<>
|
|
||||||
char *toString(const MyPoint &point)
|
|
||||||
{
|
|
||||||
QByteArray ba = "MyPoint(";
|
|
||||||
ba += QByteArray::number(point.x()) + ", " + QByteArray::number(point.y());
|
|
||||||
ba += ')';
|
|
||||||
return qstrdup(ba.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//! [16]
|
|
||||||
|
|
||||||
//! [toString-overload]
|
|
||||||
namespace MyNamespace {
|
|
||||||
char *toString(const MyPoint &point)
|
|
||||||
{
|
|
||||||
// bring QTest::toString overloads into scope:
|
|
||||||
using QTest::toString;
|
|
||||||
// delegate char* handling to QTest::toString(QByteArray):
|
|
||||||
return toString("MyPoint(" +
|
|
||||||
QByteArray::number(point.x()) + ", " +
|
|
||||||
QByteArray::number(point.y()) + ')');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//! [toString-overload]
|
|
||||||
|
|
||||||
//! [18]
|
//! [18]
|
||||||
MyTestObject test1;
|
MyTestObject test1;
|
||||||
QTest::qExec(&test1);
|
QTest::qExec(&test1);
|
||||||
//! [18]
|
//! [18]
|
||||||
|
}
|
||||||
|
|
||||||
|
void tstQDir()
|
||||||
|
{
|
||||||
//! [19]
|
//! [19]
|
||||||
QDir dir;
|
QDir dir;
|
||||||
|
|
||||||
QTest::ignoreMessage(QtWarningMsg, "QDir::mkdir: Empty or null file name(s)");
|
QTest::ignoreMessage(QtWarningMsg, "QDir::mkdir: Empty or null file name(s)");
|
||||||
dir.mkdir("");
|
dir.mkdir("");
|
||||||
//! [19]
|
//! [19]
|
||||||
|
}
|
||||||
|
|
||||||
//! [20]
|
//! [20]
|
||||||
void myTestFunction_data()
|
void MyTestClass::addSingleStringRows()
|
||||||
{
|
{
|
||||||
QTest::addColumn<QString>("aString");
|
QTest::addColumn<QString>("aString");
|
||||||
QTest::newRow("just hello") << QString("hello");
|
QTest::newRow("just hello") << QString("hello");
|
||||||
@ -200,152 +184,65 @@ void myTestFunction_data()
|
|||||||
}
|
}
|
||||||
//! [20]
|
//! [20]
|
||||||
|
|
||||||
|
void MyTestClass::addMultStringRows()
|
||||||
//! [addRow]
|
|
||||||
void myTestFunction_data()
|
|
||||||
{
|
{
|
||||||
|
//! [addRow]
|
||||||
QTest::addColumn<int>("input");
|
QTest::addColumn<int>("input");
|
||||||
QTest::addColumn<QString>("output");
|
QTest::addColumn<QString>("output");
|
||||||
QTest::addRow("%d", 0) << 0 << QString("0");
|
QTest::addRow("%d", 0) << 0 << QString("0");
|
||||||
QTest::addRow("%d", 1) << 1 << QString("1");
|
QTest::addRow("%d", 1) << 1 << QString("1");
|
||||||
}
|
|
||||||
//! [addRow]
|
//! [addRow]
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyTestClass::addDataRow()
|
||||||
|
{
|
||||||
//! [21]
|
//! [21]
|
||||||
void myTestFunction_data() {
|
|
||||||
QTest::addColumn<int>("intval");
|
QTest::addColumn<int>("intval");
|
||||||
QTest::addColumn<QString>("str");
|
QTest::addColumn<QString>("str");
|
||||||
QTest::addColumn<double>("dbl");
|
QTest::addColumn<double>("dbl");
|
||||||
|
|
||||||
QTest::newRow("row1") << 1 << "hello" << 1.5;
|
QTest::newRow("row1") << 1 << "hello" << 1.5;
|
||||||
}
|
|
||||||
//! [21]
|
//! [21]
|
||||||
|
}
|
||||||
|
|
||||||
//! [22]
|
//! [22]
|
||||||
void MyTestClass::cleanup()
|
void MyTestClass::cleanup()
|
||||||
{
|
{
|
||||||
if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
|
if (qstrcmp(QTest::currentTestFunction(), "myDatabaseTest") == 0) {
|
||||||
// clean up all database connections
|
// clean up all database connections
|
||||||
closeAllDatabases();
|
closeAllDatabases();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! [22]
|
//! [22]
|
||||||
|
|
||||||
|
void mySleep()
|
||||||
|
{
|
||||||
//! [23]
|
//! [23]
|
||||||
QTest::qSleep(250);
|
QTest::qSleep(250);
|
||||||
//! [23]
|
//! [23]
|
||||||
|
|
||||||
|
|
||||||
//! [25]
|
|
||||||
QTouchDevice *dev = QTest::createTouchDevice();
|
|
||||||
QWidget widget;
|
|
||||||
|
|
||||||
QTest::touchEvent(&widget, dev)
|
|
||||||
.press(0, QPoint(10, 10));
|
|
||||||
QTest::touchEvent(&widget, dev)
|
|
||||||
.stationary(0)
|
|
||||||
.press(1, QPoint(40, 10));
|
|
||||||
QTest::touchEvent(&widget, dev)
|
|
||||||
.move(0, QPoint(12, 12))
|
|
||||||
.move(1, QPoint(45, 5));
|
|
||||||
QTest::touchEvent(&widget, dev)
|
|
||||||
.release(0, QPoint(12, 12))
|
|
||||||
.release(1, QPoint(45, 5));
|
|
||||||
//! [25]
|
|
||||||
|
|
||||||
|
|
||||||
//! [26]
|
|
||||||
// Source: /home/user/sources/myxmlparser/tests/tst_myxmlparser/tst_myxmlparser.cpp
|
|
||||||
// Build: /home/user/build/myxmlparser/tests/tst_myxmlparser
|
|
||||||
// Qt: /usr/local/Qt-5.0.0
|
|
||||||
void tst_MyXmlParser::parse()
|
|
||||||
{
|
|
||||||
MyXmlParser parser;
|
|
||||||
QString input = QFINDTESTDATA("testxml/simple1.xml");
|
|
||||||
QVERIFY(parser.parse(input));
|
|
||||||
}
|
}
|
||||||
//! [26]
|
|
||||||
|
|
||||||
//! [27]
|
//! [27]
|
||||||
void TestBenchmark::simple()
|
void TestBenchmark::simple()
|
||||||
{
|
{
|
||||||
QString str1 = QLatin1String("This is a test string");
|
QString str1 = QLatin1String("This is a test string");
|
||||||
QString str2 = QLatin1String("This is a test string");
|
QString str2 = QLatin1String("This is a test string");
|
||||||
|
|
||||||
QCOMPARE(str1.localeAwareCompare(str2), 0);
|
QCOMPARE(str1.localeAwareCompare(str2), 0);
|
||||||
|
|
||||||
QBENCHMARK {
|
QBENCHMARK {
|
||||||
str1.localeAwareCompare(str2);
|
str1.localeAwareCompare(str2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//! [27]
|
//! [27]
|
||||||
|
|
||||||
//! [28]
|
void verifyString()
|
||||||
QTest::keyClick(myWindow, 'a');
|
|
||||||
//! [28]
|
|
||||||
|
|
||||||
|
|
||||||
//! [29]
|
|
||||||
QTest::keyClick(myWindow, Qt::Key_Escape);
|
|
||||||
|
|
||||||
QTest::keyClick(myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200);
|
|
||||||
//! [29]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//! [30]
|
|
||||||
void TestQLocale::initTestCase_data()
|
|
||||||
{
|
{
|
||||||
QTest::addColumn<QLocale>("locale");
|
QFile file;
|
||||||
QTest::newRow("C") << QLocale::c();
|
|
||||||
QTest::newRow("UKish") << QLocale("en_GB");
|
|
||||||
QTest::newRow("USAish") << QLocale(QLocale::English);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQLocale::roundTripInt_data()
|
|
||||||
{
|
|
||||||
QTest::addColumn<int>("number");
|
|
||||||
QTest::newRow("one") << 1;
|
|
||||||
QTest::newRow("two") << 2;
|
|
||||||
QTest::newRow("ten") << 10;
|
|
||||||
}
|
|
||||||
//! [30]
|
|
||||||
|
|
||||||
//! [31]
|
|
||||||
void TestQLocale::roundTripInt()
|
|
||||||
{
|
|
||||||
QFETCH_GLOBAL(QLocale, locale);
|
|
||||||
QFETCH(int, number);
|
|
||||||
bool ok;
|
|
||||||
QCOMPARE(locale.toInt(locale.toString(number), &ok), number);
|
|
||||||
QVERIFY(ok);
|
|
||||||
}
|
|
||||||
//! [31]
|
|
||||||
|
|
||||||
|
|
||||||
//! [32]
|
//! [32]
|
||||||
bool opened = file.open(QIODevice::WriteOnly);
|
bool opened = file.open(QIODevice::WriteOnly);
|
||||||
QVERIFY(opened);
|
QVERIFY(opened);
|
||||||
//! [32]
|
//! [32]
|
||||||
|
|
||||||
|
|
||||||
//! [33]
|
//! [33]
|
||||||
QVERIFY2(file.open(QIODevice::WriteOnly),
|
QVERIFY2(file.open(QIODevice::WriteOnly),
|
||||||
qPrintable(QString("open %1: %2").arg(file.fileName()).arg(file.errorString()));
|
qPrintable(QString("open %1: %2")
|
||||||
|
.arg(file.fileName()).arg(file.errorString())));
|
||||||
//! [33]
|
//! [33]
|
||||||
|
|
||||||
//! [34]
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
namespace QTest {
|
|
||||||
template <> char *toString<MyType>(const MyType &t)
|
|
||||||
{
|
|
||||||
char *repr = new char[t.reprSize()];
|
|
||||||
t.writeRepr(repr);
|
|
||||||
return repr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QT_END_NAMESPACE
|
|
||||||
//! [34]
|
|
||||||
|
168
src/testlib/doc/snippets/code/src_qtestlib_qtestcase_snippet.cpp
Normal file
168
src/testlib/doc/snippets/code/src_qtestlib_qtestcase_snippet.cpp
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2020 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of the documentation of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** BSD License Usage
|
||||||
|
** Alternatively, you may use this file under the terms of the BSD license
|
||||||
|
** as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of The Qt Company Ltd nor the names of its
|
||||||
|
** contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
//! [0]
|
||||||
|
QVERIFY(spy.isValid());
|
||||||
|
//! [0]
|
||||||
|
|
||||||
|
//! [13]
|
||||||
|
QTest::keyClick(myWidget, 'a');
|
||||||
|
//! [13]
|
||||||
|
|
||||||
|
//! [14]
|
||||||
|
QTest::keyClick(myWidget, Qt::Key_Escape);
|
||||||
|
|
||||||
|
QTest::keyClick(myWidget, Qt::Key_Escape, Qt::ShiftModifier, 200);
|
||||||
|
//! [14]
|
||||||
|
|
||||||
|
//! [15]
|
||||||
|
QTest::keyClicks(myWidget, "hello world");
|
||||||
|
//! [15]
|
||||||
|
|
||||||
|
//! [16]
|
||||||
|
namespace QTest {
|
||||||
|
template<>
|
||||||
|
char *toString(const MyPoint &point)
|
||||||
|
{
|
||||||
|
const QByteArray ba("MyPoint("
|
||||||
|
+ QByteArray::number(point.x()) + ", "
|
||||||
|
+ QByteArray::number(point.y()) + ')');
|
||||||
|
return qstrdup(ba.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//! [16]
|
||||||
|
|
||||||
|
//! [toString-overload]
|
||||||
|
namespace {
|
||||||
|
char *toString(const MyPoint &point)
|
||||||
|
{
|
||||||
|
return QTest::toString("MyPoint(" +
|
||||||
|
QByteArray::number(point.x()) + ", " +
|
||||||
|
QByteArray::number(point.y()) + ')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//! [toString-overload]
|
||||||
|
|
||||||
|
void processTouchEvent()
|
||||||
|
{
|
||||||
|
//! [25]
|
||||||
|
QTouchDevice *dev = QTest::createTouchDevice();
|
||||||
|
QWidget widget;
|
||||||
|
|
||||||
|
QTest::touchEvent(&widget, dev)
|
||||||
|
.press(0, QPoint(10, 10));
|
||||||
|
QTest::touchEvent(&widget, dev)
|
||||||
|
.stationary(0)
|
||||||
|
.press(1, QPoint(40, 10));
|
||||||
|
QTest::touchEvent(&widget, dev)
|
||||||
|
.move(0, QPoint(12, 12))
|
||||||
|
.move(1, QPoint(45, 5));
|
||||||
|
QTest::touchEvent(&widget, dev)
|
||||||
|
.release(0, QPoint(12, 12))
|
||||||
|
.release(1, QPoint(45, 5));
|
||||||
|
//! [25]
|
||||||
|
}
|
||||||
|
|
||||||
|
//! [26]
|
||||||
|
bool tst_MyXmlParser::parse()
|
||||||
|
{
|
||||||
|
MyXmlParser parser;
|
||||||
|
QString input = QFINDTESTDATA("testxml/simple1.xml");
|
||||||
|
QVERIFY(parser.parse(input));
|
||||||
|
}
|
||||||
|
//! [26]
|
||||||
|
|
||||||
|
//! [28]
|
||||||
|
QWidget myWindow;
|
||||||
|
QTest::keyClick(&myWindow, Qt::Key_Tab);
|
||||||
|
//! [28]
|
||||||
|
|
||||||
|
//! [29]
|
||||||
|
QTest::keyClick(&myWindow, Qt::Key_Escape);
|
||||||
|
QTest::keyClick(&myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200);
|
||||||
|
//! [29]
|
||||||
|
|
||||||
|
//! [30]
|
||||||
|
void TestQLocale::initTestCase_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QLocale>("locale");
|
||||||
|
QTest::newRow("C") << QLocale::c();
|
||||||
|
QTest::newRow("UKish") << QLocale("en_GB");
|
||||||
|
QTest::newRow("USAish") << QLocale(QLocale::English, QLocale::UnitedStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestQLocale::roundTripInt_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<int>("number");
|
||||||
|
QTest::newRow("zero") << 0;
|
||||||
|
QTest::newRow("one") << 1;
|
||||||
|
QTest::newRow("two") << 2;
|
||||||
|
QTest::newRow("ten") << 10;
|
||||||
|
}
|
||||||
|
//! [30]
|
||||||
|
|
||||||
|
//! [31]
|
||||||
|
void TestQLocale::roundTripInt()
|
||||||
|
{
|
||||||
|
QFETCH_GLOBAL(QLocale, locale);
|
||||||
|
QFETCH(int, number);
|
||||||
|
bool ok;
|
||||||
|
QCOMPARE(locale.toInt(locale.toString(number), &ok), number);
|
||||||
|
QVERIFY(ok);
|
||||||
|
}
|
||||||
|
//! [31]
|
||||||
|
|
||||||
|
//! [34]
|
||||||
|
char *toString(const MyType &t)
|
||||||
|
{
|
||||||
|
char *repr = new char[t.reprSize()];
|
||||||
|
t.writeRepr(repr);
|
||||||
|
return repr;
|
||||||
|
}
|
||||||
|
//! [34]
|
10
src/testlib/doc/snippets/snippets.pro
Normal file
10
src/testlib/doc/snippets/snippets.pro
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
TEMPLATE = app
|
||||||
|
TARGET = testlib_cppsnippet
|
||||||
|
QT = core testlib sql widgets
|
||||||
|
|
||||||
|
SOURCES += code/src_qtestlib_qtestcase.cpp \
|
||||||
|
code/doc_src_qtestlib.cpp \
|
||||||
|
code/doc_src_qtestevent.cpp \
|
||||||
|
code/doc_src_qtqskip.cpp \
|
||||||
|
code/doc_src_qttest.cpp \
|
||||||
|
code/src_corelib_kernel_qtestsupport_core.cpp
|
@ -475,7 +475,7 @@
|
|||||||
For example, to test each number provided by \c {roundTripInt_data()} with
|
For example, to test each number provided by \c {roundTripInt_data()} with
|
||||||
each locale provided by \c {initTestCase_data()}:
|
each locale provided by \c {initTestCase_data()}:
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 31
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 31
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -902,7 +902,7 @@
|
|||||||
|
|
||||||
Example of QSKIP in a test function:
|
Example of QSKIP in a test function:
|
||||||
|
|
||||||
\snippet code/doc_src_qtqskip.cpp 0
|
\snippet code/doc_src_qtqskip_snippet.cpp 0
|
||||||
|
|
||||||
In a data-driven test, each call to QSKIP() skips only the current
|
In a data-driven test, each call to QSKIP() skips only the current
|
||||||
row of test data. If the data-driven test contains an unconditional
|
row of test data. If the data-driven test contains an unconditional
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
For example, the following code shows this macro being used to verify that a
|
For example, the following code shows this macro being used to verify that a
|
||||||
\l QSignalSpy object is valid:
|
\l QSignalSpy object is valid:
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 0
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 0
|
||||||
|
|
||||||
For more information about the failure, use \c QCOMPARE(x, y) instead of
|
For more information about the failure, use \c QCOMPARE(x, y) instead of
|
||||||
\c QVERIFY(x == y), because it reports both the expected and actual value
|
\c QVERIFY(x == y), because it reports both the expected and actual value
|
||||||
@ -136,7 +136,7 @@
|
|||||||
outputting into the test log.
|
outputting into the test log.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 34
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 34
|
||||||
|
|
||||||
The return from \c toString() must be a \c {new char []}. That is, it shall
|
The return from \c toString() must be a \c {new char []}. That is, it shall
|
||||||
be released with \c delete[] (rather than \c free() or plain \c delete) once
|
be released with \c delete[] (rather than \c free() or plain \c delete) once
|
||||||
@ -306,14 +306,16 @@
|
|||||||
|
|
||||||
Assuming a test has the following data:
|
Assuming a test has the following data:
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 30
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 30
|
||||||
|
|
||||||
The test's own data is a single number per row. In this case,
|
The test's own data is a single number per row. In this case,
|
||||||
\c initTestCase_data() also supplies a locale per row. Therefore,
|
\c initTestCase_data() also supplies a locale per row. Therefore,
|
||||||
this test will be run with every combination of locale from the
|
this test will be run with every combination of locale from the
|
||||||
latter and number from the former.
|
latter and number from the former. Thus, with four rows in the
|
||||||
|
global table and three in the local, the test function is run for
|
||||||
|
12 distinct test-cases (4 * 3 = 12).
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 31
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 31
|
||||||
|
|
||||||
The locale is read from the global data table using QFETCH_GLOBAL(),
|
The locale is read from the global data table using QFETCH_GLOBAL(),
|
||||||
and the number is read from the local data table using QFETCH().
|
and the number is read from the local data table using QFETCH().
|
||||||
@ -492,7 +494,7 @@
|
|||||||
a warning is printed to the test log.
|
a warning is printed to the test log.
|
||||||
|
|
||||||
For example, in this code:
|
For example, in this code:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 26
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 26
|
||||||
|
|
||||||
The testdata file will be resolved as the first existing file from:
|
The testdata file will be resolved as the first existing file from:
|
||||||
|
|
||||||
@ -656,7 +658,7 @@
|
|||||||
before clicking the key.
|
before clicking the key.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 14
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 14
|
||||||
|
|
||||||
The first example above simulates clicking the \c escape key on \c
|
The first example above simulates clicking the \c escape key on \c
|
||||||
myWidget without any keyboard modifiers and without delay. The
|
myWidget without any keyboard modifiers and without delay. The
|
||||||
@ -674,7 +676,7 @@
|
|||||||
before clicking the key.
|
before clicking the key.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 13
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 13
|
||||||
|
|
||||||
The example above simulates clicking \c a on \c myWidget without
|
The example above simulates clicking \c a on \c myWidget without
|
||||||
any keyboard modifiers and without delay of the test.
|
any keyboard modifiers and without delay of the test.
|
||||||
@ -700,7 +702,7 @@
|
|||||||
before clicking the key.
|
before clicking the key.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 29
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 29
|
||||||
|
|
||||||
The first example above simulates clicking the \c escape key on \c
|
The first example above simulates clicking the \c escape key on \c
|
||||||
myWindow without any keyboard modifiers and without delay. The
|
myWindow without any keyboard modifiers and without delay. The
|
||||||
@ -719,7 +721,7 @@
|
|||||||
before clicking the key.
|
before clicking the key.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 28
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 28
|
||||||
|
|
||||||
The example above simulates clicking \c a on \c myWindow without
|
The example above simulates clicking \c a on \c myWindow without
|
||||||
any keyboard modifiers and without delay of the test.
|
any keyboard modifiers and without delay of the test.
|
||||||
@ -865,7 +867,7 @@
|
|||||||
click.
|
click.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 15
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 15
|
||||||
|
|
||||||
The example above simulates clicking the sequence of keys
|
The example above simulates clicking the sequence of keys
|
||||||
representing "hello world" on \c myWidget without any keyboard
|
representing "hello world" on \c myWidget without any keyboard
|
||||||
@ -1040,12 +1042,12 @@
|
|||||||
\note The caller of toString() must delete the returned data
|
\note The caller of toString() must delete the returned data
|
||||||
using \c{delete[]}. Your implementation should return a string
|
using \c{delete[]}. Your implementation should return a string
|
||||||
created with \c{new[]} or qstrdup(). The easiest way to do so is to
|
created with \c{new[]} or qstrdup(). The easiest way to do so is to
|
||||||
create a QByteArray or QString and calling QTest::toString() on it
|
create a QByteArray or QString and call QTest::toString() on it
|
||||||
(see second example below).
|
(see second example below).
|
||||||
|
|
||||||
Example for specializing (Qt ≤ 5.4):
|
Example for specializing (Qt ≤ 5.4):
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 16
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 16
|
||||||
|
|
||||||
The example above defines a toString() specialization for a class
|
The example above defines a toString() specialization for a class
|
||||||
called \c MyPoint. Whenever a comparison of two instances of \c
|
called \c MyPoint. Whenever a comparison of two instances of \c
|
||||||
@ -1054,7 +1056,7 @@
|
|||||||
|
|
||||||
Same example, but with overloading (Qt ≥ 5.5):
|
Same example, but with overloading (Qt ≥ 5.5):
|
||||||
|
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp toString-overload
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp toString-overload
|
||||||
|
|
||||||
\sa QCOMPARE()
|
\sa QCOMPARE()
|
||||||
*/
|
*/
|
||||||
@ -1273,7 +1275,7 @@
|
|||||||
instance run out of scope to commit the sequence to the event system.
|
instance run out of scope to commit the sequence to the event system.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
\snippet code/src_qtestlib_qtestcase.cpp 25
|
\snippet code/src_qtestlib_qtestcase_snippet.cpp 25
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
Loading…
Reference in New Issue
Block a user