diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-04-07 23:59:05 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-04-07 23:59:05 (GMT) |
commit | 99ba0cf26ddd0b45c809ae72868006eb94153545 (patch) | |
tree | a258ae81162b6e467864dde6d088df7ce37f816f /tests | |
parent | 46082389f2a700a1f98826e0c575ab4e31059761 (diff) | |
parent | 45614d67061f31dce9791293b8fde516e39037d5 (diff) | |
download | Qt-99ba0cf26ddd0b45c809ae72868006eb94153545.zip Qt-99ba0cf26ddd0b45c809ae72868006eb94153545.tar.gz Qt-99ba0cf26ddd0b45c809ae72868006eb94153545.tar.bz2 |
Merge remote branch 'qa-review/master' into qa-staging-master
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qpointer/tst_qpointer.cpp | 110 | ||||
-rw-r--r-- | tests/auto/xmlpatterns/stderrBaselines/Passhelp.txt | 16 |
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 |