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 | |
30 | #include <QtCore/QCoreApplication> |
31 | #include <QtTest/QtTest> |
32 | |
33 | /*! |
34 | \internal |
35 | \since 4.4 |
36 | \brief Tests that reporting of tables are done in a certain way. |
37 | */ |
38 | class tst_DataTable: public QObject |
39 | { |
40 | Q_OBJECT |
41 | |
42 | private slots: |
43 | void singleTestFunction1() const; |
44 | void singleTestFunction2() const; |
45 | |
46 | void fiveTablePasses() const; |
47 | void fiveTablePasses_data() const; |
48 | void fiveTableFailures() const; |
49 | void fiveTableFailures_data() const; |
50 | |
51 | void startsWithFailure() const; |
52 | void startsWithFailure_data() const; |
53 | |
54 | void endsWithFailure() const; |
55 | void endsWithFailure_data() const; |
56 | |
57 | void failureInMiddle() const; |
58 | void failureInMiddle_data() const; |
59 | |
60 | void fiveIsolatedFailures() const; |
61 | void fiveIsolatedFailures_data() const; |
62 | }; |
63 | |
64 | void tst_DataTable::singleTestFunction1() const |
65 | { |
66 | /* Do nothing, just pass. */ |
67 | } |
68 | |
69 | void tst_DataTable::singleTestFunction2() const |
70 | { |
71 | /* Do nothing, just pass. */ |
72 | } |
73 | |
74 | void tst_DataTable::fiveTableFailures() const |
75 | { |
76 | QFETCH(bool, test); |
77 | |
78 | QVERIFY(test); |
79 | } |
80 | |
81 | void tst_DataTable::fiveTableFailures_data() const |
82 | { |
83 | QTest::addColumn<bool>(name: "test" ); |
84 | |
85 | /* Unconditionally fail. */ |
86 | QTest::newRow(dataTag: "fiveTableFailures_data 1" ) << false; |
87 | QTest::newRow(dataTag: "fiveTableFailures_data 2" ) << false; |
88 | QTest::newRow(dataTag: "fiveTableFailures_data 3" ) << false; |
89 | QTest::newRow(dataTag: "fiveTableFailures_data 4" ) << false; |
90 | QTest::newRow(dataTag: "fiveTableFailures_data 5" ) << false; |
91 | } |
92 | |
93 | void tst_DataTable::startsWithFailure() const |
94 | { |
95 | fiveTableFailures(); |
96 | } |
97 | |
98 | void tst_DataTable::fiveTablePasses() const |
99 | { |
100 | fiveTableFailures(); |
101 | } |
102 | |
103 | void tst_DataTable::fiveTablePasses_data() const |
104 | { |
105 | QTest::addColumn<bool>(name: "test" ); |
106 | |
107 | QTest::newRow(dataTag: "fiveTablePasses_data 1" ) << true; |
108 | QTest::newRow(dataTag: "fiveTablePasses_data 2" ) << true; |
109 | QTest::newRow(dataTag: "fiveTablePasses_data 3" ) << true; |
110 | QTest::newRow(dataTag: "fiveTablePasses_data 4" ) << true; |
111 | QTest::newRow(dataTag: "fiveTablePasses_data 5" ) << true; |
112 | } |
113 | |
114 | void tst_DataTable::startsWithFailure_data() const |
115 | { |
116 | QTest::addColumn<bool>(name: "test" ); |
117 | |
118 | QTest::newRow(dataTag: "startsWithFailure_data 1" ) << false; |
119 | QTest::newRow(dataTag: "startsWithFailure_data 2" ) << true; |
120 | QTest::newRow(dataTag: "startsWithFailure_data 3" ) << true; |
121 | QTest::newRow(dataTag: "startsWithFailure_data 4" ) << true; |
122 | QTest::newRow(dataTag: "startsWithFailure_data 5" ) << true; |
123 | } |
124 | |
125 | void tst_DataTable::endsWithFailure() const |
126 | { |
127 | fiveTableFailures(); |
128 | } |
129 | |
130 | void tst_DataTable::endsWithFailure_data() const |
131 | { |
132 | QTest::addColumn<bool>(name: "test" ); |
133 | |
134 | QTest::newRow(dataTag: "endsWithFailure 1" ) << true; |
135 | QTest::newRow(dataTag: "endsWithFailure 2" ) << true; |
136 | QTest::newRow(dataTag: "endsWithFailure 3" ) << true; |
137 | QTest::newRow(dataTag: "endsWithFailure 4" ) << true; |
138 | QTest::newRow(dataTag: "endsWithFailure 5" ) << false; |
139 | } |
140 | |
141 | void tst_DataTable::failureInMiddle() const |
142 | { |
143 | fiveTableFailures(); |
144 | } |
145 | |
146 | void tst_DataTable::failureInMiddle_data() const |
147 | { |
148 | QTest::addColumn<bool>(name: "test" ); |
149 | |
150 | QTest::newRow(dataTag: "failureInMiddle_data 1" ) << true; |
151 | QTest::newRow(dataTag: "failureInMiddle_data 2" ) << true; |
152 | QTest::newRow(dataTag: "failureInMiddle_data 3" ) << false; |
153 | QTest::newRow(dataTag: "failureInMiddle_data 4" ) << true; |
154 | QTest::newRow(dataTag: "failureInMiddle_data 5" ) << true; |
155 | } |
156 | |
157 | void tst_DataTable::fiveIsolatedFailures() const |
158 | { |
159 | QFETCH(bool, test); |
160 | QVERIFY(!test); |
161 | } |
162 | |
163 | void tst_DataTable::fiveIsolatedFailures_data() const |
164 | { |
165 | QTest::addColumn<bool>(name: "test" ); |
166 | |
167 | QTest::newRow(dataTag: "fiveIsolatedFailures_data 1" ) << true; |
168 | QTest::newRow(dataTag: "fiveIsolatedFailures_data 2" ) << true; |
169 | QTest::newRow(dataTag: "fiveIsolatedFailures_data 3" ) << true; |
170 | QTest::newRow(dataTag: "fiveIsolatedFailures_data 4" ) << true; |
171 | QTest::newRow(dataTag: "fiveIsolatedFailures_data 5" ) << true; |
172 | } |
173 | |
174 | QTEST_MAIN(tst_DataTable) |
175 | |
176 | #include "tst_datatable.moc" |
177 | |