1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include <QtTest/QtTest>
30
31class tst_Xunit : public QObject
32{
33 Q_OBJECT
34
35public:
36 tst_Xunit();
37
38private slots:
39 void testFunc1();
40 void testFunc2();
41 void testFunc3();
42 void testFunc4();
43 void testFunc5();
44 void testFunc6();
45 void testFunc7();
46};
47
48tst_Xunit::tst_Xunit()
49{
50}
51
52void tst_Xunit::testFunc1()
53{
54 QWARN("just a QWARN() !");
55 QCOMPARE(1,1);
56}
57
58void tst_Xunit::testFunc2()
59{
60 qDebug(msg: "a qDebug() call with comment-ending stuff -->");
61 QCOMPARE(2, 3);
62}
63
64void tst_Xunit::testFunc3()
65{
66 QSKIP("skipping this function!");
67}
68
69void tst_Xunit::testFunc4()
70{
71 QFAIL("a forced failure!");
72}
73
74/*
75 Note there are two testfunctions which give expected failures.
76 This is so we can test that expected failures don't add to failure
77 counts and unexpected passes do. If we had one xfail and one xpass
78 testfunction, we couldn't test which one of them adds to the failure
79 count.
80*/
81
82void tst_Xunit::testFunc5()
83{
84 QEXPECT_FAIL("", "this failure is expected", Abort);
85 QVERIFY(false);
86}
87
88void tst_Xunit::testFunc6()
89{
90 QEXPECT_FAIL("", "this failure is also expected", Abort);
91 QVERIFY(false);
92}
93
94void tst_Xunit::testFunc7()
95{
96 QEXPECT_FAIL("", "this pass is unexpected", Abort);
97 QVERIFY(true);
98}
99
100
101QTEST_APPLESS_MAIN(tst_Xunit)
102#include "tst_xunit.moc"
103

source code of qtbase/tests/auto/testlib/selftests/xunit/tst_xunit.cpp