@@ -1,343 +1,436 | |||||
1 | /**************************************************************************** |
|
1 | /**************************************************************************** | |
2 | ** |
|
2 | ** | |
3 | ** Copyright (C) 2012 Digia Plc |
|
3 | ** Copyright (C) 2012 Digia Plc | |
4 | ** All rights reserved. |
|
4 | ** All rights reserved. | |
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com |
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |
6 | ** |
|
6 | ** | |
7 | ** This file is part of the Qt Commercial Charts Add-on. |
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |
8 | ** |
|
8 | ** | |
9 | ** $QT_BEGIN_LICENSE$ |
|
9 | ** $QT_BEGIN_LICENSE$ | |
10 | ** Licensees holding valid Qt Commercial licenses may use this file in |
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |
11 | ** accordance with the Qt Commercial License Agreement provided with the |
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |
12 | ** Software or, alternatively, in accordance with the terms contained in |
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |
13 | ** a written agreement between you and Digia. |
|
13 | ** a written agreement between you and Digia. | |
14 | ** |
|
14 | ** | |
15 | ** If you have questions regarding the use of this file, please use |
|
15 | ** If you have questions regarding the use of this file, please use | |
16 | ** contact form at http://qt.digia.com |
|
16 | ** contact form at http://qt.digia.com | |
17 | ** $QT_END_LICENSE$ |
|
17 | ** $QT_END_LICENSE$ | |
18 | ** |
|
18 | ** | |
19 | ****************************************************************************/ |
|
19 | ****************************************************************************/ | |
20 |
|
20 | |||
21 | #include <QtTest/QtTest> |
|
21 | #include <QtTest/QtTest> | |
22 | #include <qbarset.h> |
|
22 | #include <qbarset.h> | |
23 |
|
23 | |||
24 | QTCOMMERCIALCHART_USE_NAMESPACE |
|
24 | QTCOMMERCIALCHART_USE_NAMESPACE | |
25 |
|
25 | |||
26 | class tst_QBarSet : public QObject |
|
26 | class tst_QBarSet : public QObject | |
27 | { |
|
27 | { | |
28 | Q_OBJECT |
|
28 | Q_OBJECT | |
29 |
|
29 | |||
30 | public slots: |
|
30 | public slots: | |
31 | void initTestCase(); |
|
31 | void initTestCase(); | |
32 | void cleanupTestCase(); |
|
32 | void cleanupTestCase(); | |
33 | void init(); |
|
33 | void init(); | |
34 | void cleanup(); |
|
34 | void cleanup(); | |
35 |
|
35 | |||
36 | private slots: |
|
36 | private slots: | |
37 | void qbarset_data(); |
|
37 | void qbarset_data(); | |
38 | void qbarset(); |
|
38 | void qbarset(); | |
39 | void name_data(); |
|
39 | void name_data(); | |
40 | void name(); |
|
40 | void name(); | |
41 | void append_data(); |
|
41 | void append_data(); | |
42 | void append(); |
|
42 | void append(); | |
43 | void appendOperator_data(); |
|
43 | void appendOperator_data(); | |
44 | void appendOperator(); |
|
44 | void appendOperator(); | |
45 | void insert_data(); |
|
45 | void insert_data(); | |
46 | void insert(); |
|
46 | void insert(); | |
47 | void remove_data(); |
|
47 | void remove_data(); | |
48 | void remove(); |
|
48 | void remove(); | |
49 | void replace_data(); |
|
49 | void replace_data(); | |
50 | void replace(); |
|
50 | void replace(); | |
51 | void at_data(); |
|
51 | void at_data(); | |
52 | void at(); |
|
52 | void at(); | |
53 | void atOperator_data(); |
|
53 | void atOperator_data(); | |
54 | void atOperator(); |
|
54 | void atOperator(); | |
55 | void count_data(); |
|
55 | void count_data(); | |
56 | void count(); |
|
56 | void count(); | |
57 | void sum_data(); |
|
57 | void sum_data(); | |
58 | void sum(); |
|
58 | void sum(); | |
|
59 | void setPen_data(); | |||
|
60 | void setPen(); | |||
|
61 | void setBrush_data(); | |||
|
62 | void setBrush(); | |||
|
63 | void setLabelPen_data(); | |||
|
64 | void setLabelPen(); | |||
|
65 | void setLabelBrush_data(); | |||
|
66 | void setLabelBrush(); | |||
|
67 | void setLabelFont_data(); | |||
|
68 | void setLabelFont(); | |||
|
69 | ||||
59 | private: |
|
70 | private: | |
60 | QBarSet* m_barset; |
|
71 | QBarSet* m_barset; | |
61 | }; |
|
72 | }; | |
62 |
|
73 | |||
63 | void tst_QBarSet::initTestCase() |
|
74 | void tst_QBarSet::initTestCase() | |
64 | { |
|
75 | { | |
65 | } |
|
76 | } | |
66 |
|
77 | |||
67 | void tst_QBarSet::cleanupTestCase() |
|
78 | void tst_QBarSet::cleanupTestCase() | |
68 | { |
|
79 | { | |
69 | } |
|
80 | } | |
70 |
|
81 | |||
71 | void tst_QBarSet::init() |
|
82 | void tst_QBarSet::init() | |
72 | { |
|
83 | { | |
73 | m_barset = new QBarSet(QString("Name")); |
|
84 | m_barset = new QBarSet(QString("Name")); | |
74 | } |
|
85 | } | |
75 |
|
86 | |||
76 | void tst_QBarSet::cleanup() |
|
87 | void tst_QBarSet::cleanup() | |
77 | { |
|
88 | { | |
78 | delete m_barset; |
|
89 | delete m_barset; | |
79 | m_barset = 0; |
|
90 | m_barset = 0; | |
80 | } |
|
91 | } | |
81 |
|
92 | |||
82 | void tst_QBarSet::qbarset_data() |
|
93 | void tst_QBarSet::qbarset_data() | |
83 | { |
|
94 | { | |
84 | } |
|
95 | } | |
85 |
|
96 | |||
86 | void tst_QBarSet::qbarset() |
|
97 | void tst_QBarSet::qbarset() | |
87 | { |
|
98 | { | |
88 | QBarSet barset(QString("Name")); |
|
99 | QBarSet barset(QString("Name")); | |
89 | QCOMPARE(barset.name(), QString("Name")); |
|
100 | QCOMPARE(barset.name(), QString("Name")); | |
90 | QCOMPARE(barset.count(), 0); |
|
101 | QCOMPARE(barset.count(), 0); | |
91 | QVERIFY(qFuzzyIsNull(barset.sum())); |
|
102 | QVERIFY(qFuzzyIsNull(barset.sum())); | |
92 | } |
|
103 | } | |
93 |
|
104 | |||
94 | void tst_QBarSet::name_data() |
|
105 | void tst_QBarSet::name_data() | |
95 | { |
|
106 | { | |
96 | QTest::addColumn<QString> ("name"); |
|
107 | QTest::addColumn<QString> ("name"); | |
97 | QTest::addColumn<QString> ("result"); |
|
108 | QTest::addColumn<QString> ("result"); | |
98 | QTest::newRow("name0") << QString("name0") << QString("name0"); |
|
109 | QTest::newRow("name0") << QString("name0") << QString("name0"); | |
99 | QTest::newRow("name1") << QString("name1") << QString("name1"); |
|
110 | QTest::newRow("name1") << QString("name1") << QString("name1"); | |
100 | } |
|
111 | } | |
101 |
|
112 | |||
102 | void tst_QBarSet::name() |
|
113 | void tst_QBarSet::name() | |
103 | { |
|
114 | { | |
104 | QFETCH(QString, name); |
|
115 | QFETCH(QString, name); | |
105 | QFETCH(QString, result); |
|
116 | QFETCH(QString, result); | |
106 |
|
117 | |||
107 | m_barset->setName(name); |
|
118 | m_barset->setName(name); | |
108 | QCOMPARE(m_barset->name(), result); |
|
119 | QCOMPARE(m_barset->name(), result); | |
109 | } |
|
120 | } | |
110 |
|
121 | |||
111 | void tst_QBarSet::append_data() |
|
122 | void tst_QBarSet::append_data() | |
112 | { |
|
123 | { | |
113 | QTest::addColumn<int> ("count"); |
|
124 | QTest::addColumn<int> ("count"); | |
114 | QTest::newRow("0") << 0; |
|
125 | QTest::newRow("0") << 0; | |
115 | QTest::newRow("5") << 5; |
|
126 | QTest::newRow("5") << 5; | |
116 | QTest::newRow("100") << 100; |
|
127 | QTest::newRow("100") << 100; | |
117 | QTest::newRow("1000") << 1000; |
|
128 | QTest::newRow("1000") << 1000; | |
118 | } |
|
129 | } | |
119 |
|
130 | |||
120 | void tst_QBarSet::append() |
|
131 | void tst_QBarSet::append() | |
121 | { |
|
132 | { | |
122 | QFETCH(int, count); |
|
133 | QFETCH(int, count); | |
123 |
|
134 | |||
124 | QCOMPARE(m_barset->count(), 0); |
|
135 | QCOMPARE(m_barset->count(), 0); | |
125 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
136 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
126 |
|
137 | |||
127 | qreal sum(0.0); |
|
138 | qreal sum(0.0); | |
128 | qreal value(0.0); |
|
139 | qreal value(0.0); | |
129 |
|
140 | |||
130 | for (int i=0; i<count; i++) { |
|
141 | for (int i=0; i<count; i++) { | |
131 | m_barset->append(value); |
|
142 | m_barset->append(value); | |
132 | QCOMPARE(m_barset->at(i), value); |
|
143 | QCOMPARE(m_barset->at(i), value); | |
133 | sum += value; |
|
144 | sum += value; | |
134 | value += 1.0; |
|
145 | value += 1.0; | |
135 | } |
|
146 | } | |
136 |
|
147 | |||
137 | QCOMPARE(m_barset->count(), count); |
|
148 | QCOMPARE(m_barset->count(), count); | |
138 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); |
|
149 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); | |
139 | } |
|
150 | } | |
140 |
|
151 | |||
141 | void tst_QBarSet::appendOperator_data() |
|
152 | void tst_QBarSet::appendOperator_data() | |
142 | { |
|
153 | { | |
143 | append_data(); |
|
154 | append_data(); | |
144 | } |
|
155 | } | |
145 |
|
156 | |||
146 | void tst_QBarSet::appendOperator() |
|
157 | void tst_QBarSet::appendOperator() | |
147 | { |
|
158 | { | |
148 | QFETCH(int, count); |
|
159 | QFETCH(int, count); | |
149 |
|
160 | |||
150 | QCOMPARE(m_barset->count(), 0); |
|
161 | QCOMPARE(m_barset->count(), 0); | |
151 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
162 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
152 |
|
163 | |||
153 | qreal sum(0.0); |
|
164 | qreal sum(0.0); | |
154 | qreal value(0.0); |
|
165 | qreal value(0.0); | |
155 |
|
166 | |||
156 | for (int i=0; i<count; i++) { |
|
167 | for (int i=0; i<count; i++) { | |
157 | *m_barset << value; |
|
168 | *m_barset << value; | |
158 | QCOMPARE(m_barset->at(i), value); |
|
169 | QCOMPARE(m_barset->at(i), value); | |
159 | sum += value; |
|
170 | sum += value; | |
160 | value += 1.0; |
|
171 | value += 1.0; | |
161 | } |
|
172 | } | |
162 |
|
173 | |||
163 | QCOMPARE(m_barset->count(), count); |
|
174 | QCOMPARE(m_barset->count(), count); | |
164 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); |
|
175 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); | |
165 | } |
|
176 | } | |
166 |
|
177 | |||
167 | void tst_QBarSet::insert_data() |
|
178 | void tst_QBarSet::insert_data() | |
168 | { |
|
179 | { | |
169 | } |
|
180 | } | |
170 |
|
181 | |||
171 | void tst_QBarSet::insert() |
|
182 | void tst_QBarSet::insert() | |
172 | { |
|
183 | { | |
173 | QCOMPARE(m_barset->count(), 0); |
|
184 | QCOMPARE(m_barset->count(), 0); | |
174 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
185 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
175 |
|
186 | |||
176 | m_barset->insert(0, 1.0); // 1.0 |
|
187 | m_barset->insert(0, 1.0); // 1.0 | |
177 | QCOMPARE(m_barset->at(0), 1.0); |
|
188 | QCOMPARE(m_barset->at(0), 1.0); | |
178 | QCOMPARE(m_barset->count(), 1); |
|
189 | QCOMPARE(m_barset->count(), 1); | |
179 | QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); |
|
190 | QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); | |
180 |
|
191 | |||
181 | m_barset->insert(0, 2.0); // 2.0 1.0 |
|
192 | m_barset->insert(0, 2.0); // 2.0 1.0 | |
182 | QCOMPARE(m_barset->at(0), 2.0); |
|
193 | QCOMPARE(m_barset->at(0), 2.0); | |
183 | QCOMPARE(m_barset->at(1), 1.0); |
|
194 | QCOMPARE(m_barset->at(1), 1.0); | |
184 | QCOMPARE(m_barset->count(), 2); |
|
195 | QCOMPARE(m_barset->count(), 2); | |
185 | QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); |
|
196 | QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); | |
186 |
|
197 | |||
187 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 |
|
198 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 | |
188 | QCOMPARE(m_barset->at(1), 3.0); |
|
199 | QCOMPARE(m_barset->at(1), 3.0); | |
189 | QCOMPARE(m_barset->at(0), 2.0); |
|
200 | QCOMPARE(m_barset->at(0), 2.0); | |
190 | QCOMPARE(m_barset->at(2), 1.0); |
|
201 | QCOMPARE(m_barset->at(2), 1.0); | |
191 | QCOMPARE(m_barset->count(), 3); |
|
202 | QCOMPARE(m_barset->count(), 3); | |
192 | QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); |
|
203 | QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); | |
193 | } |
|
204 | } | |
194 |
|
205 | |||
195 | void tst_QBarSet::remove_data() |
|
206 | void tst_QBarSet::remove_data() | |
196 | { |
|
207 | { | |
197 | } |
|
208 | } | |
198 |
|
209 | |||
199 | void tst_QBarSet::remove() |
|
210 | void tst_QBarSet::remove() | |
200 | { |
|
211 | { | |
201 | QCOMPARE(m_barset->count(), 0); |
|
212 | QCOMPARE(m_barset->count(), 0); | |
202 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
213 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
203 |
|
214 | |||
204 | m_barset->append(1.0); |
|
215 | m_barset->append(1.0); | |
205 | m_barset->append(2.0); |
|
216 | m_barset->append(2.0); | |
206 | m_barset->append(3.0); |
|
217 | m_barset->append(3.0); | |
207 | m_barset->append(4.0); |
|
218 | m_barset->append(4.0); | |
208 |
|
219 | |||
209 | QCOMPARE(m_barset->count(), 4); |
|
220 | QCOMPARE(m_barset->count(), 4); | |
210 | QCOMPARE(m_barset->sum(), 10.0); |
|
221 | QCOMPARE(m_barset->sum(), 10.0); | |
211 |
|
222 | |||
212 | m_barset->remove(2); // 1.0 2.0 4.0 |
|
223 | m_barset->remove(2); // 1.0 2.0 4.0 | |
213 | QCOMPARE(m_barset->at(0), 1.0); |
|
224 | QCOMPARE(m_barset->at(0), 1.0); | |
214 | QCOMPARE(m_barset->at(1), 2.0); |
|
225 | QCOMPARE(m_barset->at(1), 2.0); | |
215 | QCOMPARE(m_barset->at(2), 4.0); |
|
226 | QCOMPARE(m_barset->at(2), 4.0); | |
216 | QCOMPARE(m_barset->count(), 3); |
|
227 | QCOMPARE(m_barset->count(), 3); | |
217 | QCOMPARE(m_barset->sum(), 7.0); |
|
228 | QCOMPARE(m_barset->sum(), 7.0); | |
218 |
|
229 | |||
219 | m_barset->remove(0); // 2.0 4.0 |
|
230 | m_barset->remove(0); // 2.0 4.0 | |
220 | QCOMPARE(m_barset->at(0), 2.0); |
|
231 | QCOMPARE(m_barset->at(0), 2.0); | |
221 | QCOMPARE(m_barset->at(1), 4.0); |
|
232 | QCOMPARE(m_barset->at(1), 4.0); | |
222 | QCOMPARE(m_barset->count(), 2); |
|
233 | QCOMPARE(m_barset->count(), 2); | |
223 | QCOMPARE(m_barset->sum(), 6.0); |
|
234 | QCOMPARE(m_barset->sum(), 6.0); | |
224 | } |
|
235 | } | |
225 |
|
236 | |||
226 | void tst_QBarSet::replace_data() |
|
237 | void tst_QBarSet::replace_data() | |
227 | { |
|
238 | { | |
228 |
|
239 | |||
229 | } |
|
240 | } | |
230 |
|
241 | |||
231 | void tst_QBarSet::replace() |
|
242 | void tst_QBarSet::replace() | |
232 | { |
|
243 | { | |
233 | QCOMPARE(m_barset->count(), 0); |
|
244 | QCOMPARE(m_barset->count(), 0); | |
234 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
245 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
235 |
|
246 | |||
236 | m_barset->append(1.0); |
|
247 | m_barset->append(1.0); | |
237 | m_barset->append(2.0); |
|
248 | m_barset->append(2.0); | |
238 | m_barset->append(3.0); |
|
249 | m_barset->append(3.0); | |
239 | m_barset->append(4.0); |
|
250 | m_barset->append(4.0); | |
240 |
|
251 | |||
241 | QCOMPARE(m_barset->count(), 4); |
|
252 | QCOMPARE(m_barset->count(), 4); | |
242 | QCOMPARE(m_barset->sum(), 10.0); |
|
253 | QCOMPARE(m_barset->sum(), 10.0); | |
243 |
|
254 | |||
244 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 |
|
255 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 | |
245 | QCOMPARE(m_barset->count(), 4); |
|
256 | QCOMPARE(m_barset->count(), 4); | |
246 | QCOMPARE(m_barset->sum(), 14.0); |
|
257 | QCOMPARE(m_barset->sum(), 14.0); | |
247 | QCOMPARE(m_barset->at(0), 5.0); |
|
258 | QCOMPARE(m_barset->at(0), 5.0); | |
248 |
|
259 | |||
249 | m_barset->replace(3, 6.0); |
|
260 | m_barset->replace(3, 6.0); | |
250 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
261 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
251 | QCOMPARE(m_barset->sum(), 16.0); |
|
262 | QCOMPARE(m_barset->sum(), 16.0); | |
252 | QCOMPARE(m_barset->at(0), 5.0); |
|
263 | QCOMPARE(m_barset->at(0), 5.0); | |
253 | QCOMPARE(m_barset->at(1), 2.0); |
|
264 | QCOMPARE(m_barset->at(1), 2.0); | |
254 | QCOMPARE(m_barset->at(2), 3.0); |
|
265 | QCOMPARE(m_barset->at(2), 3.0); | |
255 | QCOMPARE(m_barset->at(3), 6.0); |
|
266 | QCOMPARE(m_barset->at(3), 6.0); | |
256 | } |
|
267 | } | |
257 |
|
268 | |||
258 | void tst_QBarSet::at_data() |
|
269 | void tst_QBarSet::at_data() | |
259 | { |
|
270 | { | |
260 |
|
271 | |||
261 | } |
|
272 | } | |
262 |
|
273 | |||
263 | void tst_QBarSet::at() |
|
274 | void tst_QBarSet::at() | |
264 | { |
|
275 | { | |
265 | QCOMPARE(m_barset->count(), 0); |
|
276 | QCOMPARE(m_barset->count(), 0); | |
266 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
277 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
267 |
|
278 | |||
268 | m_barset->append(1.0); |
|
279 | m_barset->append(1.0); | |
269 | m_barset->append(2.0); |
|
280 | m_barset->append(2.0); | |
270 | m_barset->append(3.0); |
|
281 | m_barset->append(3.0); | |
271 | m_barset->append(4.0); |
|
282 | m_barset->append(4.0); | |
272 |
|
283 | |||
273 | QCOMPARE(m_barset->at(0), 1.0); |
|
284 | QCOMPARE(m_barset->at(0), 1.0); | |
274 | QCOMPARE(m_barset->at(1), 2.0); |
|
285 | QCOMPARE(m_barset->at(1), 2.0); | |
275 | QCOMPARE(m_barset->at(2), 3.0); |
|
286 | QCOMPARE(m_barset->at(2), 3.0); | |
276 | QCOMPARE(m_barset->at(3), 4.0); |
|
287 | QCOMPARE(m_barset->at(3), 4.0); | |
277 | } |
|
288 | } | |
278 |
|
289 | |||
279 | void tst_QBarSet::atOperator_data() |
|
290 | void tst_QBarSet::atOperator_data() | |
280 | { |
|
291 | { | |
281 |
|
292 | |||
282 | } |
|
293 | } | |
283 |
|
294 | |||
284 | void tst_QBarSet::atOperator() |
|
295 | void tst_QBarSet::atOperator() | |
285 | { |
|
296 | { | |
286 | QCOMPARE(m_barset->count(), 0); |
|
297 | QCOMPARE(m_barset->count(), 0); | |
287 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
298 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
288 |
|
299 | |||
289 | m_barset->append(1.0); |
|
300 | m_barset->append(1.0); | |
290 | m_barset->append(2.0); |
|
301 | m_barset->append(2.0); | |
291 | m_barset->append(3.0); |
|
302 | m_barset->append(3.0); | |
292 | m_barset->append(4.0); |
|
303 | m_barset->append(4.0); | |
293 |
|
304 | |||
294 | QCOMPARE(m_barset->operator [](0), 1.0); |
|
305 | QCOMPARE(m_barset->operator [](0), 1.0); | |
295 | QCOMPARE(m_barset->operator [](1), 2.0); |
|
306 | QCOMPARE(m_barset->operator [](1), 2.0); | |
296 | QCOMPARE(m_barset->operator [](2), 3.0); |
|
307 | QCOMPARE(m_barset->operator [](2), 3.0); | |
297 | QCOMPARE(m_barset->operator [](3), 4.0); |
|
308 | QCOMPARE(m_barset->operator [](3), 4.0); | |
298 | } |
|
309 | } | |
299 |
|
310 | |||
300 | void tst_QBarSet::count_data() |
|
311 | void tst_QBarSet::count_data() | |
301 | { |
|
312 | { | |
302 |
|
313 | |||
303 | } |
|
314 | } | |
304 |
|
315 | |||
305 | void tst_QBarSet::count() |
|
316 | void tst_QBarSet::count() | |
306 | { |
|
317 | { | |
307 | QCOMPARE(m_barset->count(), 0); |
|
318 | QCOMPARE(m_barset->count(), 0); | |
308 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
319 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
309 |
|
320 | |||
310 | m_barset->append(1.0); |
|
321 | m_barset->append(1.0); | |
311 | QCOMPARE(m_barset->count(),1); |
|
322 | QCOMPARE(m_barset->count(),1); | |
312 | m_barset->append(2.0); |
|
323 | m_barset->append(2.0); | |
313 | QCOMPARE(m_barset->count(),2); |
|
324 | QCOMPARE(m_barset->count(),2); | |
314 | m_barset->append(3.0); |
|
325 | m_barset->append(3.0); | |
315 | QCOMPARE(m_barset->count(),3); |
|
326 | QCOMPARE(m_barset->count(),3); | |
316 | m_barset->append(4.0); |
|
327 | m_barset->append(4.0); | |
317 | QCOMPARE(m_barset->count(),4); |
|
328 | QCOMPARE(m_barset->count(),4); | |
318 | } |
|
329 | } | |
319 |
|
330 | |||
320 | void tst_QBarSet::sum_data() |
|
331 | void tst_QBarSet::sum_data() | |
321 | { |
|
332 | { | |
322 |
|
333 | |||
323 | } |
|
334 | } | |
324 |
|
335 | |||
325 | void tst_QBarSet::sum() |
|
336 | void tst_QBarSet::sum() | |
326 | { |
|
337 | { | |
327 | QCOMPARE(m_barset->count(), 0); |
|
338 | QCOMPARE(m_barset->count(), 0); | |
328 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
339 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
329 |
|
340 | |||
330 | m_barset->append(1.0); |
|
341 | m_barset->append(1.0); | |
331 | QVERIFY(qFuzzyCompare(m_barset->sum(),1.0)); |
|
342 | QVERIFY(qFuzzyCompare(m_barset->sum(),1.0)); | |
332 | m_barset->append(2.0); |
|
343 | m_barset->append(2.0); | |
333 | QVERIFY(qFuzzyCompare(m_barset->sum(),3.0)); |
|
344 | QVERIFY(qFuzzyCompare(m_barset->sum(),3.0)); | |
334 | m_barset->append(3.0); |
|
345 | m_barset->append(3.0); | |
335 | QVERIFY(qFuzzyCompare(m_barset->sum(),6.0)); |
|
346 | QVERIFY(qFuzzyCompare(m_barset->sum(),6.0)); | |
336 | m_barset->append(4.0); |
|
347 | m_barset->append(4.0); | |
337 | QVERIFY(qFuzzyCompare(m_barset->sum(),10.0)); |
|
348 | QVERIFY(qFuzzyCompare(m_barset->sum(),10.0)); | |
338 | } |
|
349 | } | |
339 |
|
350 | |||
|
351 | void tst_QBarSet::setPen_data() | |||
|
352 | { | |||
|
353 | ||||
|
354 | } | |||
|
355 | ||||
|
356 | void tst_QBarSet::setPen() | |||
|
357 | { | |||
|
358 | QVERIFY(m_barset->pen() == QPen()); | |||
|
359 | ||||
|
360 | QPen pen; | |||
|
361 | pen.setColor(QColor(128,128,128,128)); | |||
|
362 | m_barset->setPen(pen); | |||
|
363 | ||||
|
364 | QVERIFY(m_barset->pen() == pen); | |||
|
365 | } | |||
|
366 | ||||
|
367 | void tst_QBarSet::setBrush_data() | |||
|
368 | { | |||
|
369 | ||||
|
370 | } | |||
|
371 | ||||
|
372 | void tst_QBarSet::setBrush() | |||
|
373 | { | |||
|
374 | QVERIFY(m_barset->brush() == QBrush()); | |||
|
375 | ||||
|
376 | QBrush brush; | |||
|
377 | brush.setColor(QColor(128,128,128,128)); | |||
|
378 | m_barset->setBrush(brush); | |||
|
379 | ||||
|
380 | QVERIFY(m_barset->brush() == brush); | |||
|
381 | } | |||
|
382 | ||||
|
383 | void tst_QBarSet::setLabelPen_data() | |||
|
384 | { | |||
|
385 | ||||
|
386 | } | |||
|
387 | ||||
|
388 | void tst_QBarSet::setLabelPen() | |||
|
389 | { | |||
|
390 | QVERIFY(m_barset->labelPen() == QPen()); | |||
|
391 | ||||
|
392 | QPen pen; | |||
|
393 | pen.setColor(QColor(128,128,128,128)); | |||
|
394 | m_barset->setLabelPen(pen); | |||
|
395 | ||||
|
396 | QVERIFY(m_barset->labelPen() == pen); | |||
|
397 | } | |||
|
398 | ||||
|
399 | void tst_QBarSet::setLabelBrush_data() | |||
|
400 | { | |||
|
401 | ||||
|
402 | } | |||
|
403 | ||||
|
404 | void tst_QBarSet::setLabelBrush() | |||
|
405 | { | |||
|
406 | QVERIFY(m_barset->labelBrush() == QBrush()); | |||
|
407 | ||||
|
408 | QBrush brush; | |||
|
409 | brush.setColor(QColor(128,128,128,128)); | |||
|
410 | m_barset->setLabelBrush(brush); | |||
|
411 | ||||
|
412 | QVERIFY(m_barset->labelBrush() == brush); | |||
|
413 | } | |||
|
414 | ||||
|
415 | void tst_QBarSet::setLabelFont_data() | |||
|
416 | { | |||
|
417 | ||||
|
418 | } | |||
|
419 | ||||
|
420 | void tst_QBarSet::setLabelFont() | |||
|
421 | { | |||
|
422 | QVERIFY(m_barset->labelFont() == QFont()); | |||
|
423 | ||||
|
424 | QFont font; | |||
|
425 | font.setBold(true); | |||
|
426 | font.setItalic(true); | |||
|
427 | m_barset->setLabelFont(font); | |||
|
428 | ||||
|
429 | QVERIFY(m_barset->labelFont() == font); | |||
|
430 | } | |||
|
431 | ||||
|
432 | ||||
340 | QTEST_MAIN(tst_QBarSet) |
|
433 | QTEST_MAIN(tst_QBarSet) | |
341 |
|
434 | |||
342 | #include "tst_qbarset.moc" |
|
435 | #include "tst_qbarset.moc" | |
343 |
|
436 |
General Comments 0
You need to be logged in to leave comments.
Login now