summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-04-09 03:31:00 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-04-09 03:31:00 (GMT)
commit8c836fa76043c55432dd4b2a1669a895e0758925 (patch)
treeaeb253c2624ce77f92d36f70a3d79594ea15a38b /tests
parent53f053d311798ba28af5602f1d9755c61c9a0549 (diff)
parent99ba0cf26ddd0b45c809ae72868006eb94153545 (diff)
downloadQt-8c836fa76043c55432dd4b2a1669a895e0758925.zip
Qt-8c836fa76043c55432dd4b2a1669a895e0758925.tar.gz
Qt-8c836fa76043c55432dd4b2a1669a895e0758925.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qa-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-qa-staging: Fix typos in QSharedPointer documentation. Remove test for compiler correctness Refactor qpointer dereference tests Prefer QCOMPARE to QVERIFY for comparisons. Improve coverage of qpointer autotest Add comments, eliminate duplication in qpointer autotest. Remove redundant includes and functions from qpointer autotest. Fix tst_XmlPatterns::xquerySupport() autotest Update copyright year to 2011. BM2: Little fix to make the `make check-trusted' to work on Linux and Windows.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qpointer/tst_qpointer.cpp110
-rw-r--r--tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt16
2 files changed, 44 insertions, 82 deletions
diff --git a/tests/auto/qpointer/tst_qpointer.cpp b/tests/auto/qpointer/tst_qpointer.cpp
index 0485a17..67579fd 100644
--- a/tests/auto/qpointer/tst_qpointer.cpp
+++ b/tests/auto/qpointer/tst_qpointer.cpp
@@ -39,11 +39,8 @@
**
****************************************************************************/
-
#include <QtTest/QtTest>
-#include <QApplication>
-#include <QDebug>
#include <QPointer>
#include <QWidget>
@@ -51,17 +48,9 @@ class tst_QPointer : public QObject
{
Q_OBJECT
public:
- tst_QPointer();
- ~tst_QPointer();
-
inline tst_QPointer *me() const
{ return const_cast<tst_QPointer *>(this); }
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
private slots:
void constructors();
void destructor();
@@ -71,29 +60,9 @@ private slots:
void dereference_operators();
void disconnect();
void castDuringDestruction();
- void data() const;
- void dataSignature() const;
void threadSafety();
};
-tst_QPointer::tst_QPointer()
-{ }
-
-tst_QPointer::~tst_QPointer()
-{ }
-
-void tst_QPointer::initTestCase()
-{ }
-
-void tst_QPointer::cleanupTestCase()
-{ }
-
-void tst_QPointer::init()
-{ }
-
-void tst_QPointer::cleanup()
-{ }
-
void tst_QPointer::constructors()
{
QPointer<QObject> p1;
@@ -106,11 +75,20 @@ void tst_QPointer::constructors()
void tst_QPointer::destructor()
{
+ // Make two QPointer's to the same object
QObject *object = new QObject;
- QPointer<QObject> p = object;
- QCOMPARE(p, QPointer<QObject>(object));
+ QPointer<QObject> p1 = object;
+ QPointer<QObject> p2 = object;
+ // Check that they point to the correct object
+ QCOMPARE(p1, QPointer<QObject>(object));
+ QCOMPARE(p2, QPointer<QObject>(object));
+ QCOMPARE(p1, p2);
+ // Destroy the guarded object
delete object;
- QCOMPARE(p, QPointer<QObject>(0));
+ // Check that both pointers were zeroed
+ QCOMPARE(p1, QPointer<QObject>(0));
+ QCOMPARE(p2, QPointer<QObject>(0));
+ QCOMPARE(p1, p2);
}
void tst_QPointer::assignment_operators()
@@ -118,19 +96,21 @@ void tst_QPointer::assignment_operators()
QPointer<QObject> p1;
QPointer<QObject> p2;
+ // Test assignment with a QObject-derived object pointer
p1 = this;
p2 = p1;
-
QCOMPARE(p1, QPointer<QObject>(this));
QCOMPARE(p2, QPointer<QObject>(this));
QCOMPARE(p1, QPointer<QObject>(p2));
+ // Test assignment with a null pointer
p1 = 0;
p2 = p1;
QCOMPARE(p1, QPointer<QObject>(0));
QCOMPARE(p2, QPointer<QObject>(0));
QCOMPARE(p1, QPointer<QObject>(p2));
+ // Test assignment with a real QObject pointer
QObject *object = new QObject;
p1 = object;
@@ -139,10 +119,15 @@ void tst_QPointer::assignment_operators()
QCOMPARE(p2, QPointer<QObject>(object));
QCOMPARE(p1, QPointer<QObject>(p2));
- delete object;
- QCOMPARE(p1, QPointer<QObject>(0));
- QCOMPARE(p2, QPointer<QObject>(0));
+ // Test assignment with the same pointer that's already guarded
+ p1 = object;
+ p2 = p1;
+ QCOMPARE(p1, QPointer<QObject>(object));
+ QCOMPARE(p2, QPointer<QObject>(object));
QCOMPARE(p1, QPointer<QObject>(p2));
+
+ // Cleanup
+ delete object;
}
void tst_QPointer::equality_operators()
@@ -196,19 +181,28 @@ void tst_QPointer::isNull()
void tst_QPointer::dereference_operators()
{
QPointer<tst_QPointer> p1 = this;
+ QPointer<tst_QPointer> p2;
+ // operator->() -- only makes sense if not null
QObject *object = p1->me();
- QVERIFY(object == this);
+ QCOMPARE(object, this);
+ // operator*() -- only makes sense if not null
QObject &ref = *p1;
- QVERIFY(&ref == this);
+ QCOMPARE(&ref, this);
+
+ // operator T*()
+ QCOMPARE(static_cast<QObject *>(p1), this);
+ QCOMPARE(static_cast<QObject *>(p2), static_cast<QObject *>(0));
- object = static_cast<QObject *>(p1);
- QVERIFY(object == this);
+ // data()
+ QCOMPARE(p1.data(), this);
+ QCOMPARE(p2.data(), static_cast<QObject *>(0));
}
void tst_QPointer::disconnect()
{
+ // Verify that pointer remains guarded when all signals are disconencted.
QPointer<QObject> p1 = new QObject;
QVERIFY(!p1.isNull());
p1->disconnect();
@@ -314,38 +308,6 @@ void tst_QPointer::castDuringDestruction()
}
}
-void tst_QPointer::data() const
-{
- /* Check value of a default constructed object. */
- {
- QPointer<QObject> p;
- QCOMPARE(p.data(), static_cast<QObject *>(0));
- }
-
- /* Check value of a default constructed object. */
- {
- QObject *const object = new QObject();
- QPointer<QObject> p(object);
- QCOMPARE(p.data(), object);
- }
-}
-
-void tst_QPointer::dataSignature() const
-{
- /* data() should be const. */
- {
- const QPointer<QObject> p;
- p.data();
- }
-
- /* The return type should be T. */
- {
- const QPointer<QWidget> p;
- /* If the types differs, the QCOMPARE will fail to instansiate. */
- QCOMPARE(p.data(), static_cast<QWidget *>(0));
- }
-}
-
class TestRunnable : public QObject, public QRunnable {
void run() {
QPointer<QObject> obj1 = new QObject;
diff --git a/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt
index 4e789e7..4a86f75 100644
--- a/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt
+++ b/tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt
@@ -1,28 +1,28 @@
xmlpatterns -- A tool for running XQuery queries.
- - When appearing, any following options are not
+ - When appearing, any following options are not
interpreted as switches.
-help Displays this help.
- -initial-template <string> The name of the initial template to call as a
+ -initial-template <string> The name of the initial template to call as a
Clark Name.
- -is-uri If specified, all filenames on the command line
+ -is-uri If specified, all filenames on the command line
are interpreted as URIs instead of a local
filenames.
- -no-format By default output is formatted for readability.
+ -no-format By default output is formatted for readability.
When specified, strict serialization is
performed.
- -output <local file> A local file to which the output should be
+ -output <local file> A local file to which the output should be
written. The file is overwritten, or if not
exist, created. If absent, stdout is used.
- -param <name=value> Binds an external variable. The value is
+ -param <name=value> Binds an external variable. The value is
directly available using the variable
reference: $name.
-version Displays version information.
- focus <string> The document to use as focus. Mandatory in case
+ focus <string> The document to use as focus. Mandatory in case
a stylesheet is used. This option is also
affected by the is-uris option.
- query/stylesheet <string> A local filename pointing to the query to run.
+ query/stylesheet <string> A local filename pointing to the query to run.
If the name ends with .xsl it's assumed to be
an XSL-T stylesheet. If it ends with .xq, it's
assumed to be an XQuery query. (In other cases