summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/crashes/tst_crashes.cpp2
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml49
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.txt21
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml52
-rw-r--r--tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml31
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.lightxml14
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.txt6
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xml14
-rw-r--r--tests/auto/testlib/selftests/expected_warnings.xunitxml11
-rw-r--r--tests/auto/testlib/selftests/selftests.pri1
-rw-r--r--tests/auto/testlib/selftests/selftests.qrc4
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp4
-rw-r--r--tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp162
-rw-r--r--tests/auto/testlib/selftests/verifyexceptionthrown/verifyexceptionthrown.pro8
-rw-r--r--tests/auto/testlib/selftests/warnings/tst_warnings.cpp17
15 files changed, 393 insertions, 3 deletions
diff --git a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
index 067c2a9f4f..3b73d87876 100644
--- a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
+++ b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
@@ -57,7 +57,7 @@ private slots:
void tst_Crashes::crash()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
//we avoid the error dialogbox to appear on windows
SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml
new file mode 100644
index 0000000000..6ef857c6d0
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml
@@ -0,0 +1,49 @@
+<Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+</Environment>
+<TestFunction name="initTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectStdTypes">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectStdExceptions">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectMyExceptions">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testFailInt">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="128">
+ <Description><![CDATA[Expected exception of type double to be thrown but unknown exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailStdString">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="133">
+ <Description><![CDATA[Expected exception of type char* to be thrown but unknown exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailStdRuntimeError">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="138">
+ <Description><![CDATA[Expected exception of type std::runtime_error to be thrown but std::exception caught with message: logic error]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailMyException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="143">
+ <Description><![CDATA[Expected exception of type MyBaseException to be thrown but std::exception caught with message: logic error]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailMyDerivedException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="148">
+ <Description><![CDATA[Expected exception of type std::runtime_error to be thrown but std::exception caught with message: MyDerivedException]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailNoException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="153">
+ <Description><![CDATA[Expected exception of type std::exception to be thrown but no exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="cleanupTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.txt b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.txt
new file mode 100644
index 0000000000..5c40f62dd2
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.txt
@@ -0,0 +1,21 @@
+********* Start testing of tst_VerifyExceptionThrown *********
+Config: Using QtTest library @INSERT_QT_VERSION_HERE@, Qt @INSERT_QT_VERSION_HERE@
+PASS : tst_VerifyExceptionThrown::initTestCase()
+PASS : tst_VerifyExceptionThrown::testCorrectStdTypes()
+PASS : tst_VerifyExceptionThrown::testCorrectStdExceptions()
+PASS : tst_VerifyExceptionThrown::testCorrectMyExceptions()
+FAIL! : tst_VerifyExceptionThrown::testFailInt() Expected exception of type double to be thrown but unknown exception caught
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(128)]
+FAIL! : tst_VerifyExceptionThrown::testFailStdString() Expected exception of type char* to be thrown but unknown exception caught
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(133)]
+FAIL! : tst_VerifyExceptionThrown::testFailStdRuntimeError() Expected exception of type std::runtime_error to be thrown but std::exception caught with message: logic error
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(138)]
+FAIL! : tst_VerifyExceptionThrown::testFailMyException() Expected exception of type MyBaseException to be thrown but std::exception caught with message: logic error
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(143)]
+FAIL! : tst_VerifyExceptionThrown::testFailMyDerivedException() Expected exception of type std::runtime_error to be thrown but std::exception caught with message: MyDerivedException
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(148)]
+FAIL! : tst_VerifyExceptionThrown::testFailNoException() Expected exception of type std::exception to be thrown but no exception caught
+ Loc: [/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp(153)]
+PASS : tst_VerifyExceptionThrown::cleanupTestCase()
+Totals: 5 passed, 6 failed, 0 skipped
+********* Finished testing of tst_VerifyExceptionThrown *********
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml
new file mode 100644
index 0000000000..df261b72c4
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestCase name="tst_VerifyExceptionThrown">
+<Environment>
+ <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion>
+ <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion>
+</Environment>
+<TestFunction name="initTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectStdTypes">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectStdExceptions">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testCorrectMyExceptions">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+<TestFunction name="testFailInt">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="128">
+ <Description><![CDATA[Expected exception of type double to be thrown but unknown exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailStdString">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="133">
+ <Description><![CDATA[Expected exception of type char* to be thrown but unknown exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailStdRuntimeError">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="138">
+ <Description><![CDATA[Expected exception of type std::runtime_error to be thrown but std::exception caught with message: logic error]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailMyException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="143">
+ <Description><![CDATA[Expected exception of type MyBaseException to be thrown but std::exception caught with message: logic error]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailMyDerivedException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="148">
+ <Description><![CDATA[Expected exception of type std::runtime_error to be thrown but std::exception caught with message: MyDerivedException]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="testFailNoException">
+<Incident type="fail" file="/home/user/dev/qt5/qtbase/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp" line="153">
+ <Description><![CDATA[Expected exception of type std::exception to be thrown but no exception caught]]></Description>
+</Incident>
+</TestFunction>
+<TestFunction name="cleanupTestCase">
+<Incident type="pass" file="" line="0" />
+</TestFunction>
+</TestCase>
diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
new file mode 100644
index 0000000000..f49746a9af
--- /dev/null
+++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<testsuite errors="0" failures="6" tests="11" name="tst_VerifyExceptionThrown">
+ <properties>
+ <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
+ <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
+ </properties>
+ <testcase result="pass" name="initTestCase"/>
+ <testcase result="pass" name="testCorrectStdTypes"/>
+ <testcase result="pass" name="testCorrectStdExceptions"/>
+ <testcase result="pass" name="testCorrectMyExceptions"/>
+ <testcase result="fail" name="testFailInt">
+ <failure message="Expected exception of type double to be thrown but unknown exception caught" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="testFailStdString">
+ <failure message="Expected exception of type char* to be thrown but unknown exception caught" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="testFailStdRuntimeError">
+ <failure message="Expected exception of type std::runtime_error to be thrown but std::exception caught with message: logic error" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="testFailMyException">
+ <failure message="Expected exception of type MyBaseException to be thrown but std::exception caught with message: logic error" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="testFailMyDerivedException">
+ <failure message="Expected exception of type std::runtime_error to be thrown but std::exception caught with message: MyDerivedException" result="fail"/>
+ </testcase>
+ <testcase result="fail" name="testFailNoException">
+ <failure message="Expected exception of type std::exception to be thrown but no exception caught" result="fail"/>
+ </testcase>
+ <testcase result="pass" name="cleanupTestCase"/>
+ <system-err/>
+</testsuite>
diff --git a/tests/auto/testlib/selftests/expected_warnings.lightxml b/tests/auto/testlib/selftests/expected_warnings.lightxml
index ad786832ca..2ad9e97449 100644
--- a/tests/auto/testlib/selftests/expected_warnings.lightxml
+++ b/tests/auto/testlib/selftests/expected_warnings.lightxml
@@ -24,6 +24,12 @@
<Message type="qdebug" file="" line="0">
<Description><![CDATA[Baba]]></Description>
</Message>
+<Message type="qdebug" file="" line="0">
+ <Description><![CDATA[Bubublabla]]></Description>
+</Message>
+<Message type="qwarn" file="" line="0">
+ <Description><![CDATA[Babablabla]]></Description>
+</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testMissingWarnings">
@@ -37,6 +43,14 @@
<Description><![CDATA[Not all expected messages were received]]></Description>
</Incident>
</TestFunction>
+<TestFunction name="testMissingWarningsRegularExpression">
+<Message type="info" file="" line="0">
+ <Description><![CDATA[Did not receive any message matching: "Warning\s\d"]]></Description>
+</Message>
+<Incident type="fail" file="" line="0">
+ <Description><![CDATA[Not all expected messages were received]]></Description>
+</Incident>
+</TestFunction>
<TestFunction name="testMissingWarningsWithData">
<Message type="info" file="" line="0">
<DataTag><![CDATA[first row]]></DataTag>
diff --git a/tests/auto/testlib/selftests/expected_warnings.txt b/tests/auto/testlib/selftests/expected_warnings.txt
index d8064651b0..e73de980cb 100644
--- a/tests/auto/testlib/selftests/expected_warnings.txt
+++ b/tests/auto/testlib/selftests/expected_warnings.txt
@@ -7,10 +7,14 @@ QDEBUG : tst_Warnings::testWarnings() Debug
QDEBUG : tst_Warnings::testWarnings() Debug
QDEBUG : tst_Warnings::testWarnings() Baba
QDEBUG : tst_Warnings::testWarnings() Baba
+QDEBUG : tst_Warnings::testWarnings() Bubublabla
+QWARN : tst_Warnings::testWarnings() Babablabla
PASS : tst_Warnings::testWarnings()
INFO : tst_Warnings::testMissingWarnings() Did not receive message: "Warning0"
INFO : tst_Warnings::testMissingWarnings() Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarnings() Not all expected messages were received
+INFO : tst_Warnings::testMissingWarningsRegularExpression() Did not receive any message matching: "Warning\s\d"
+FAIL! : tst_Warnings::testMissingWarningsRegularExpression() Not all expected messages were received
INFO : tst_Warnings::testMissingWarningsWithData(first row) Did not receive message: "Warning0"
INFO : tst_Warnings::testMissingWarningsWithData(first row) Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarningsWithData(first row) Not all expected messages were received
@@ -18,5 +22,5 @@ INFO : tst_Warnings::testMissingWarningsWithData(second row) Did not receive m
INFO : tst_Warnings::testMissingWarningsWithData(second row) Did not receive message: "Warning1"
FAIL! : tst_Warnings::testMissingWarningsWithData(second row) Not all expected messages were received
PASS : tst_Warnings::cleanupTestCase()
-Totals: 3 passed, 3 failed, 0 skipped
+Totals: 3 passed, 4 failed, 0 skipped
********* Finished testing of tst_Warnings *********
diff --git a/tests/auto/testlib/selftests/expected_warnings.xml b/tests/auto/testlib/selftests/expected_warnings.xml
index 8ad236b52a..14a45ca4fd 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xml
+++ b/tests/auto/testlib/selftests/expected_warnings.xml
@@ -26,6 +26,12 @@
<Message type="qdebug" file="" line="0">
<Description><![CDATA[Baba]]></Description>
</Message>
+<Message type="qdebug" file="" line="0">
+ <Description><![CDATA[Bubublabla]]></Description>
+</Message>
+<Message type="qwarn" file="" line="0">
+ <Description><![CDATA[Babablabla]]></Description>
+</Message>
<Incident type="pass" file="" line="0" />
</TestFunction>
<TestFunction name="testMissingWarnings">
@@ -39,6 +45,14 @@
<Description><![CDATA[Not all expected messages were received]]></Description>
</Incident>
</TestFunction>
+<TestFunction name="testMissingWarningsRegularExpression">
+<Message type="info" file="" line="0">
+ <Description><![CDATA[Did not receive any message matching: "Warning\s\d"]]></Description>
+</Message>
+<Incident type="fail" file="" line="0">
+ <Description><![CDATA[Not all expected messages were received]]></Description>
+</Incident>
+</TestFunction>
<TestFunction name="testMissingWarningsWithData">
<Message type="info" file="" line="0">
<DataTag><![CDATA[first row]]></DataTag>
diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.xunitxml
index 3e3b9ce18e..7be47174c6 100644
--- a/tests/auto/testlib/selftests/expected_warnings.xunitxml
+++ b/tests/auto/testlib/selftests/expected_warnings.xunitxml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<testsuite errors="12" failures="3" tests="5" name="tst_Warnings">
+<testsuite errors="15" failures="4" tests="6" name="tst_Warnings">
<properties>
<property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/>
<property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/>
@@ -12,12 +12,18 @@
<!-- message="Debug" type="qdebug" -->
<!-- message="Baba" type="qdebug" -->
<!-- message="Baba" type="qdebug" -->
+ <!-- message="Bubublabla" type="qdebug" -->
+ <!-- message="Babablabla" type="qwarn" -->
</testcase>
<testcase result="fail" name="testMissingWarnings">
<!-- message="Did not receive message: &quot;Warning0&quot;" type="info" -->
<!-- message="Did not receive message: &quot;Warning1&quot;" type="info" -->
<failure message="Not all expected messages were received" result="fail"/>
</testcase>
+ <testcase result="fail" name="testMissingWarningsRegularExpression">
+ <!-- message="Did not receive any message matching: &quot;Warning\s\d&quot;" type="info" -->
+ <failure message="Not all expected messages were received" result="fail"/>
+ </testcase>
<testcase result="fail" name="testMissingWarningsWithData">
<!-- tag="first row" message="Did not receive message: &quot;Warning0&quot;" type="info" -->
<!-- tag="first row" message="Did not receive message: &quot;Warning1&quot;" type="info" -->
@@ -34,8 +40,11 @@
<![CDATA[Debug]]>
<![CDATA[Baba]]>
<![CDATA[Baba]]>
+<![CDATA[Bubublabla]]>
+<![CDATA[Babablabla]]>
<![CDATA[Did not receive message: "Warning0"]]>
<![CDATA[Did not receive message: "Warning1"]]>
+<![CDATA[Did not receive any message matching: "Warning\s\d"]]>
<![CDATA[Did not receive message: "Warning0"]]>
<![CDATA[Did not receive message: "Warning1"]]>
<![CDATA[Did not receive message: "Warning0"]]>
diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri
index c9474419eb..7b706735a9 100644
--- a/tests/auto/testlib/selftests/selftests.pri
+++ b/tests/auto/testlib/selftests/selftests.pri
@@ -41,5 +41,6 @@ SUBPROGRAMS = \
subtest \
verbose1 \
verbose2 \
+ verifyexceptionthrown \
warnings \
xunit
diff --git a/tests/auto/testlib/selftests/selftests.qrc b/tests/auto/testlib/selftests/selftests.qrc
index 03de05fb89..e7ca7138b2 100644
--- a/tests/auto/testlib/selftests/selftests.qrc
+++ b/tests/auto/testlib/selftests/selftests.qrc
@@ -134,6 +134,10 @@
<file>expected_verbose2.txt</file>
<file>expected_verbose2.xml</file>
<file>expected_verbose2.xunitxml</file>
+ <file>expected_verifyexceptionthrown.lightxml</file>
+ <file>expected_verifyexceptionthrown.txt</file>
+ <file>expected_verifyexceptionthrown.xml</file>
+ <file>expected_verifyexceptionthrown.xunitxml</file>
<file>expected_warnings.lightxml</file>
<file>expected_warnings.txt</file>
<file>expected_warnings.xml</file>
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index e332f01861..1a8e336b55 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -381,6 +381,10 @@ void tst_Selftests::runSubTest_data()
<< "subtest"
<< "verbose1"
<< "verbose2"
+#ifndef QT_NO_EXCEPTIONS
+ // this test will test nothing if the exceptions are disabled
+ << "verifyexceptionthrown"
+#endif //!QT_NO_EXCEPTIONS
<< "warnings"
<< "xunit"
;
diff --git a/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp b/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp
new file mode 100644
index 0000000000..fc57f19c4f
--- /dev/null
+++ b/tests/auto/testlib/selftests/verifyexceptionthrown/tst_verifyexceptionthrown.cpp
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+
+
+#ifndef QT_NO_EXCEPTIONS
+# include <stdexcept>
+#endif
+
+
+#ifndef QT_NO_EXCEPTIONS
+
+class MyBaseException
+{
+
+};
+
+class MyDerivedException: public MyBaseException, public std::domain_error
+{
+public:
+ MyDerivedException(): std::domain_error("MyDerivedException") {}
+};
+
+
+#endif // !QT_NO_EXCEPTIONS
+
+
+class tst_VerifyExceptionThrown: public QObject
+{
+ Q_OBJECT
+private:
+ void doSomething() const {}
+
+private slots:
+// Remove all test cases if exceptions are not available
+#ifndef QT_NO_EXCEPTIONS
+ void testCorrectStdTypes() const;
+ void testCorrectStdExceptions() const;
+ void testCorrectMyExceptions() const;
+
+ void testFailInt() const;
+ void testFailStdString() const;
+ void testFailStdRuntimeError() const;
+ void testFailMyException() const;
+ void testFailMyDerivedException() const;
+
+ void testFailNoException() const;
+#endif // !QT_NO_EXCEPTIONS
+};
+
+
+
+#ifndef QT_NO_EXCEPTIONS
+
+void tst_VerifyExceptionThrown::testCorrectStdTypes() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw int(5), int);
+ QVERIFY_EXCEPTION_THROWN(throw float(9.8), float);
+ QVERIFY_EXCEPTION_THROWN(throw bool(true), bool);
+ QVERIFY_EXCEPTION_THROWN(throw std::string("some string"), std::string);
+}
+
+void tst_VerifyExceptionThrown::testCorrectStdExceptions() const
+{
+ // same type
+ QVERIFY_EXCEPTION_THROWN(throw std::exception(), std::exception);
+ QVERIFY_EXCEPTION_THROWN(throw std::runtime_error("runtime error"), std::runtime_error);
+ QVERIFY_EXCEPTION_THROWN(throw std::overflow_error("overflow error"), std::overflow_error);
+
+ // inheritance
+ QVERIFY_EXCEPTION_THROWN(throw std::overflow_error("overflow error"), std::runtime_error);
+ QVERIFY_EXCEPTION_THROWN(throw std::overflow_error("overflow error"), std::exception);
+}
+
+void tst_VerifyExceptionThrown::testCorrectMyExceptions() const
+{
+ // same type
+ QVERIFY_EXCEPTION_THROWN(throw MyBaseException(), MyBaseException);
+ QVERIFY_EXCEPTION_THROWN(throw MyDerivedException(), MyDerivedException);
+
+ // inheritance
+ QVERIFY_EXCEPTION_THROWN(throw MyDerivedException(), MyBaseException);
+ QVERIFY_EXCEPTION_THROWN(throw MyDerivedException(), std::domain_error);
+}
+
+void tst_VerifyExceptionThrown::testFailInt() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw int(5), double);
+}
+
+void tst_VerifyExceptionThrown::testFailStdString() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw std::string("some string"), char*);
+}
+
+void tst_VerifyExceptionThrown::testFailStdRuntimeError() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw std::logic_error("logic error"), std::runtime_error);
+}
+
+void tst_VerifyExceptionThrown::testFailMyException() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw std::logic_error("logic error"), MyBaseException);
+}
+
+void tst_VerifyExceptionThrown::testFailMyDerivedException() const
+{
+ QVERIFY_EXCEPTION_THROWN(throw MyDerivedException(), std::runtime_error);
+}
+
+void tst_VerifyExceptionThrown::testFailNoException() const
+{
+ QVERIFY_EXCEPTION_THROWN(doSomething(), std::exception);
+}
+
+#endif // !QT_NO_EXCEPTIONS
+
+
+
+QTEST_MAIN(tst_VerifyExceptionThrown)
+
+#include "tst_verifyexceptionthrown.moc"
diff --git a/tests/auto/testlib/selftests/verifyexceptionthrown/verifyexceptionthrown.pro b/tests/auto/testlib/selftests/verifyexceptionthrown/verifyexceptionthrown.pro
new file mode 100644
index 0000000000..51f108c9d7
--- /dev/null
+++ b/tests/auto/testlib/selftests/verifyexceptionthrown/verifyexceptionthrown.pro
@@ -0,0 +1,8 @@
+SOURCES += tst_verifyexceptionthrown.cpp
+QT = core testlib
+
+mac:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+CONFIG += exceptions
+
+TARGET = verifyexceptionthrown
diff --git a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
index 20f53fdc91..ff4357f11f 100644
--- a/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
+++ b/tests/auto/testlib/selftests/warnings/tst_warnings.cpp
@@ -41,6 +41,7 @@
#include <QtCore/QCoreApplication>
+#include <QtCore/QRegularExpression>
#include <QtTest/QtTest>
class tst_Warnings: public QObject
@@ -49,6 +50,7 @@ class tst_Warnings: public QObject
private slots:
void testWarnings();
void testMissingWarnings();
+ void testMissingWarningsRegularExpression();
void testMissingWarningsWithData_data();
void testMissingWarningsWithData();
};
@@ -73,6 +75,13 @@ void tst_Warnings::testWarnings()
qDebug("Baba");
qDebug("Bubu");
qDebug("Baba");
+
+ QTest::ignoreMessage(QtDebugMsg, QRegularExpression("^Bubu.*"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Baba.*"));
+ qDebug("Bubublabla");
+ qWarning("Babablabla");
+ qDebug("Bubublabla");
+ qWarning("Babablabla");
}
void tst_Warnings::testMissingWarnings()
@@ -84,6 +93,14 @@ void tst_Warnings::testMissingWarnings()
qWarning("Warning2");
}
+void tst_Warnings::testMissingWarningsRegularExpression()
+{
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\d\\d"));
+ QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Warning\\s\\d"));
+
+ qWarning("Warning11");
+}
+
void tst_Warnings::testMissingWarningsWithData_data()
{
QTest::addColumn<int>("dummy");