@@ -0,0 +1,6 | |||||
|
1 | !include( ../auto.pri ) { | |||
|
2 | error( "Couldn't find the auto.pri file!" ) | |||
|
3 | } | |||
|
4 | SOURCES += tst_qbarseries.cpp | |||
|
5 | ||||
|
6 | !system_build:mac: QMAKE_POST_LINK += "$$MAC_POST_LINK_PREFIX $$MAC_AUTOTESTS_BIN_DIR" |
@@ -0,0 +1,133 | |||||
|
1 | /**************************************************************************** | |||
|
2 | ** | |||
|
3 | ** Copyright (C) 2012 Digia Plc | |||
|
4 | ** All rights reserved. | |||
|
5 | ** For any questions to Digia, please use contact form at http://qt.digia.com | |||
|
6 | ** | |||
|
7 | ** This file is part of the Qt Commercial Charts Add-on. | |||
|
8 | ** | |||
|
9 | ** $QT_BEGIN_LICENSE$ | |||
|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in | |||
|
11 | ** accordance with the Qt Commercial License Agreement provided with the | |||
|
12 | ** Software or, alternatively, in accordance with the terms contained in | |||
|
13 | ** a written agreement between you and Digia. | |||
|
14 | ** | |||
|
15 | ** If you have questions regarding the use of this file, please use | |||
|
16 | ** contact form at http://qt.digia.com | |||
|
17 | ** $QT_END_LICENSE$ | |||
|
18 | ** | |||
|
19 | ****************************************************************************/ | |||
|
20 | ||||
|
21 | #include <QtTest/QtTest> | |||
|
22 | #include <qbarseries.h> | |||
|
23 | #include <qbarset> | |||
|
24 | ||||
|
25 | QTCOMMERCIALCHART_USE_NAMESPACE | |||
|
26 | ||||
|
27 | class tst_QBarSeries : public QObject | |||
|
28 | { | |||
|
29 | Q_OBJECT | |||
|
30 | ||||
|
31 | public slots: | |||
|
32 | void initTestCase(); | |||
|
33 | void cleanupTestCase(); | |||
|
34 | void init(); | |||
|
35 | void cleanup(); | |||
|
36 | ||||
|
37 | private slots: | |||
|
38 | void qbarseries_data(); | |||
|
39 | void qbarseries(); | |||
|
40 | void type_data(); | |||
|
41 | void type(); | |||
|
42 | void appendBarSet_data(); | |||
|
43 | void appendBarSet(); | |||
|
44 | ||||
|
45 | private: | |||
|
46 | QBarSeries* m_barseries; | |||
|
47 | }; | |||
|
48 | ||||
|
49 | void tst_QBarSeries::initTestCase() | |||
|
50 | { | |||
|
51 | } | |||
|
52 | ||||
|
53 | void tst_QBarSeries::cleanupTestCase() | |||
|
54 | { | |||
|
55 | } | |||
|
56 | ||||
|
57 | void tst_QBarSeries::init() | |||
|
58 | { | |||
|
59 | QBarCategories categories; | |||
|
60 | categories << "category0" << "category1" << "category2"; | |||
|
61 | m_barseries = new QBarSeries(categories); | |||
|
62 | } | |||
|
63 | ||||
|
64 | void tst_QBarSeries::cleanup() | |||
|
65 | { | |||
|
66 | delete m_barseries; | |||
|
67 | m_barseries = 0; | |||
|
68 | } | |||
|
69 | ||||
|
70 | void tst_QBarSeries::qbarseries_data() | |||
|
71 | { | |||
|
72 | QTest::addColumn<QBarCategories> ("categories"); | |||
|
73 | QBarCategories c; | |||
|
74 | c << "category0" << "category1" << "category2"; | |||
|
75 | QTest::newRow("categories") << c; | |||
|
76 | } | |||
|
77 | ||||
|
78 | void tst_QBarSeries::qbarseries() | |||
|
79 | { | |||
|
80 | QFETCH(QBarCategories, categories); | |||
|
81 | QBarSeries *barseries = new QBarSeries(categories); | |||
|
82 | QVERIFY(barseries != 0); | |||
|
83 | QBarCategories verifyCategories = barseries->categories(); | |||
|
84 | ||||
|
85 | QVERIFY(verifyCategories.count() == categories.count()); | |||
|
86 | for (int i=0; i<categories.count(); i++) { | |||
|
87 | QVERIFY(verifyCategories.at(i).compare(categories.at(i)) == 0); | |||
|
88 | } | |||
|
89 | } | |||
|
90 | ||||
|
91 | void tst_QBarSeries::type_data() | |||
|
92 | { | |||
|
93 | ||||
|
94 | } | |||
|
95 | ||||
|
96 | void tst_QBarSeries::type() | |||
|
97 | { | |||
|
98 | QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar); | |||
|
99 | } | |||
|
100 | ||||
|
101 | void tst_QBarSeries::appendBarSet_data() | |||
|
102 | { | |||
|
103 | } | |||
|
104 | ||||
|
105 | void tst_QBarSeries::appendBarSet() | |||
|
106 | { | |||
|
107 | QVERIFY(m_barseries->barsetCount() == 0); | |||
|
108 | ||||
|
109 | QBarSet *barset = new QBarSet("testset"); | |||
|
110 | m_barseries->appendBarSet(barset); | |||
|
111 | ||||
|
112 | QVERIFY(m_barseries->barsetCount() == 1); | |||
|
113 | } | |||
|
114 | ||||
|
115 | /* | |||
|
116 | void removeBarSet(QBarSet *set); // Releases ownership, doesn't delete set | |||
|
117 | void appendBarSets(QList<QBarSet* > sets); | |||
|
118 | void removeBarSets(QList<QBarSet* > sets); | |||
|
119 | int barsetCount() const; | |||
|
120 | int categoryCount() const; | |||
|
121 | QList<QBarSet*> barSets() const; | |||
|
122 | QBarCategories categories() const; | |||
|
123 | ||||
|
124 | void setLabelsVisible(bool visible = true); | |||
|
125 | ||||
|
126 | bool setModel(QAbstractItemModel *model); | |||
|
127 | void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); | |||
|
128 | void setModelMappingRange(int first, int count = -1); | |||
|
129 | */ | |||
|
130 | QTEST_MAIN(tst_QBarSeries) | |||
|
131 | ||||
|
132 | #include "tst_qbarseries.moc" | |||
|
133 |
@@ -1,10 +1,10 | |||||
1 | !include( ../test.pri ) { |
|
1 | !include( ../test.pri ) { | |
2 | error( "Couldn't find the test.pri file!" ) |
|
2 | error( "Couldn't find the test.pri file!" ) | |
3 | } |
|
3 | } | |
4 |
|
4 | |||
5 | TEMPLATE = subdirs |
|
5 | TEMPLATE = subdirs | |
6 |
SUBDIRS += qchartview qchart qlineseries |
|
6 | SUBDIRS += qchartview qchart qlineseries qbarset qbarseries | |
7 |
|
7 | |||
8 | test_private:{ |
|
8 | test_private:{ | |
9 | SUBDIRS += chartdataset domain |
|
9 | SUBDIRS += chartdataset domain | |
10 | } |
|
10 | } |
@@ -1,345 +1,343 | |||||
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 |
|
||||
60 | private: |
|
|||
61 |
|
||||
62 | private: |
|
59 | private: | |
63 | QBarSet* m_barset; |
|
60 | QBarSet* m_barset; | |
64 | }; |
|
61 | }; | |
65 |
|
62 | |||
66 | void tst_QBarSet::initTestCase() |
|
63 | void tst_QBarSet::initTestCase() | |
67 | { |
|
64 | { | |
68 | } |
|
65 | } | |
69 |
|
66 | |||
70 | void tst_QBarSet::cleanupTestCase() |
|
67 | void tst_QBarSet::cleanupTestCase() | |
71 | { |
|
68 | { | |
72 | } |
|
69 | } | |
73 |
|
70 | |||
74 | void tst_QBarSet::init() |
|
71 | void tst_QBarSet::init() | |
75 | { |
|
72 | { | |
76 | m_barset = new QBarSet(QString("Name")); |
|
73 | m_barset = new QBarSet(QString("Name")); | |
77 | } |
|
74 | } | |
78 |
|
75 | |||
79 | void tst_QBarSet::cleanup() |
|
76 | void tst_QBarSet::cleanup() | |
80 | { |
|
77 | { | |
81 | delete m_barset; |
|
78 | delete m_barset; | |
82 | m_barset = 0; |
|
79 | m_barset = 0; | |
83 | } |
|
80 | } | |
84 |
|
81 | |||
85 | void tst_QBarSet::qbarset_data() |
|
82 | void tst_QBarSet::qbarset_data() | |
86 | { |
|
83 | { | |
87 | } |
|
84 | } | |
88 |
|
85 | |||
89 | void tst_QBarSet::qbarset() |
|
86 | void tst_QBarSet::qbarset() | |
90 | { |
|
87 | { | |
91 | QBarSet barset(QString("Name")); |
|
88 | QBarSet barset(QString("Name")); | |
92 | QCOMPARE(barset.name(), QString("Name")); |
|
89 | QCOMPARE(barset.name(), QString("Name")); | |
93 | QCOMPARE(barset.count(), 0); |
|
90 | QCOMPARE(barset.count(), 0); | |
94 | QVERIFY(qFuzzyIsNull(barset.sum())); |
|
91 | QVERIFY(qFuzzyIsNull(barset.sum())); | |
95 | } |
|
92 | } | |
96 |
|
93 | |||
97 | void tst_QBarSet::name_data() |
|
94 | void tst_QBarSet::name_data() | |
98 | { |
|
95 | { | |
99 |
QTest::addColumn<QString> ("name |
|
96 | QTest::addColumn<QString> ("name"); | |
100 | QTest::newRow("name0, name1") << QString("name0") << QString("name1"); |
|
97 | QTest::addColumn<QString> ("result"); | |
|
98 | QTest::newRow("name0") << QString("name0") << QString("name0"); | |||
|
99 | QTest::newRow("name1") << QString("name1") << QString("name1"); | |||
101 | } |
|
100 | } | |
102 |
|
101 | |||
103 | void tst_QBarSet::name() |
|
102 | void tst_QBarSet::name() | |
104 | { |
|
103 | { | |
105 |
QFETCH(QString, name |
|
104 | QFETCH(QString, name); | |
|
105 | QFETCH(QString, result); | |||
106 |
|
106 | |||
107 |
m_barset->setName(name |
|
107 | m_barset->setName(name); | |
108 |
QCOMPARE(m_barset->name(), |
|
108 | QCOMPARE(m_barset->name(), result); | |
109 | } |
|
109 | } | |
110 |
|
110 | |||
111 | void tst_QBarSet::append_data() |
|
111 | void tst_QBarSet::append_data() | |
112 | { |
|
112 | { | |
113 | // QTest::addColumn<QList<qreal> >("values"); |
|
|||
114 | // QTest::newRow("0.0 1.0 2.0 3.0 4.0") << (QList<qreal>(0.0) << qreal(1.0) << qreal(2.0) << qreal(3.0) << qreal(4.0)); |
|
|||
115 | QTest::addColumn<int> ("count"); |
|
113 | QTest::addColumn<int> ("count"); | |
116 |
QTest::newRow("0 |
|
114 | QTest::newRow("0") << 0; | |
|
115 | QTest::newRow("5") << 5; | |||
|
116 | QTest::newRow("100") << 100; | |||
|
117 | QTest::newRow("1000") << 1000; | |||
117 | } |
|
118 | } | |
118 |
|
119 | |||
119 | void tst_QBarSet::append() |
|
120 | void tst_QBarSet::append() | |
120 | { |
|
121 | { | |
121 | QFETCH(int, count); |
|
122 | QFETCH(int, count); | |
122 |
|
123 | |||
123 | QCOMPARE(m_barset->count(), 0); |
|
124 | QCOMPARE(m_barset->count(), 0); | |
124 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
125 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
125 |
|
126 | |||
126 | qreal sum(0.0); |
|
127 | qreal sum(0.0); | |
127 | qreal value(0.0); |
|
128 | qreal value(0.0); | |
128 |
|
129 | |||
129 | for (int i=0; i<count; i++) { |
|
130 | for (int i=0; i<count; i++) { | |
130 | m_barset->append(value); |
|
131 | m_barset->append(value); | |
131 | QCOMPARE(m_barset->at(i), value); |
|
132 | QCOMPARE(m_barset->at(i), value); | |
132 | sum += value; |
|
133 | sum += value; | |
133 | value += 1.0; |
|
134 | value += 1.0; | |
134 | } |
|
135 | } | |
135 |
|
136 | |||
136 | QCOMPARE(m_barset->count(), count); |
|
137 | QCOMPARE(m_barset->count(), count); | |
137 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); |
|
138 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); | |
138 | } |
|
139 | } | |
139 |
|
140 | |||
140 | void tst_QBarSet::appendOperator_data() |
|
141 | void tst_QBarSet::appendOperator_data() | |
141 | { |
|
142 | { | |
142 | append_data(); |
|
143 | append_data(); | |
143 | } |
|
144 | } | |
144 |
|
145 | |||
145 | void tst_QBarSet::appendOperator() |
|
146 | void tst_QBarSet::appendOperator() | |
146 | { |
|
147 | { | |
147 | QFETCH(int, count); |
|
148 | QFETCH(int, count); | |
148 |
|
149 | |||
149 | QCOMPARE(m_barset->count(), 0); |
|
150 | QCOMPARE(m_barset->count(), 0); | |
150 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
151 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
151 |
|
152 | |||
152 | qreal sum(0.0); |
|
153 | qreal sum(0.0); | |
153 | qreal value(0.0); |
|
154 | qreal value(0.0); | |
154 |
|
155 | |||
155 | for (int i=0; i<count; i++) { |
|
156 | for (int i=0; i<count; i++) { | |
156 | *m_barset << value; |
|
157 | *m_barset << value; | |
157 | QCOMPARE(m_barset->at(i), value); |
|
158 | QCOMPARE(m_barset->at(i), value); | |
158 | sum += value; |
|
159 | sum += value; | |
159 | value += 1.0; |
|
160 | value += 1.0; | |
160 | } |
|
161 | } | |
161 |
|
162 | |||
162 | QCOMPARE(m_barset->count(), count); |
|
163 | QCOMPARE(m_barset->count(), count); | |
163 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); |
|
164 | QVERIFY(qFuzzyCompare(m_barset->sum(), sum)); | |
164 | } |
|
165 | } | |
165 |
|
166 | |||
166 | void tst_QBarSet::insert_data() |
|
167 | void tst_QBarSet::insert_data() | |
167 | { |
|
168 | { | |
168 | // TODO? |
|
|||
169 | } |
|
169 | } | |
170 |
|
170 | |||
171 | void tst_QBarSet::insert() |
|
171 | void tst_QBarSet::insert() | |
172 | { |
|
172 | { | |
173 | QCOMPARE(m_barset->count(), 0); |
|
173 | QCOMPARE(m_barset->count(), 0); | |
174 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
174 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
175 |
|
175 | |||
176 | m_barset->insert(0, 1.0); // 1.0 |
|
176 | m_barset->insert(0, 1.0); // 1.0 | |
177 | QCOMPARE(m_barset->at(0), 1.0); |
|
177 | QCOMPARE(m_barset->at(0), 1.0); | |
178 | QCOMPARE(m_barset->count(), 1); |
|
178 | QCOMPARE(m_barset->count(), 1); | |
179 |
Q |
|
179 | QVERIFY(qFuzzyCompare(m_barset->sum(), 1.0)); | |
180 |
|
180 | |||
181 | m_barset->insert(0, 2.0); // 2.0 1.0 |
|
181 | m_barset->insert(0, 2.0); // 2.0 1.0 | |
182 | QCOMPARE(m_barset->at(0), 2.0); |
|
182 | QCOMPARE(m_barset->at(0), 2.0); | |
183 | QCOMPARE(m_barset->at(1), 1.0); |
|
183 | QCOMPARE(m_barset->at(1), 1.0); | |
184 | QCOMPARE(m_barset->count(), 2); |
|
184 | QCOMPARE(m_barset->count(), 2); | |
185 |
Q |
|
185 | QVERIFY(qFuzzyCompare(m_barset->sum(), 3.0)); | |
186 |
|
186 | |||
187 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 |
|
187 | m_barset->insert(1, 3.0); // 2.0 3.0 1.0 | |
188 | QCOMPARE(m_barset->at(1), 3.0); |
|
188 | QCOMPARE(m_barset->at(1), 3.0); | |
189 | QCOMPARE(m_barset->at(0), 2.0); |
|
189 | QCOMPARE(m_barset->at(0), 2.0); | |
190 | QCOMPARE(m_barset->at(2), 1.0); |
|
190 | QCOMPARE(m_barset->at(2), 1.0); | |
191 | QCOMPARE(m_barset->count(), 3); |
|
191 | QCOMPARE(m_barset->count(), 3); | |
192 |
Q |
|
192 | QVERIFY(qFuzzyCompare(m_barset->sum(), 6.0)); | |
193 | } |
|
193 | } | |
194 |
|
194 | |||
195 | void tst_QBarSet::remove_data() |
|
195 | void tst_QBarSet::remove_data() | |
196 | { |
|
196 | { | |
197 | // TODO? |
|
|||
198 | } |
|
197 | } | |
199 |
|
198 | |||
200 | void tst_QBarSet::remove() |
|
199 | void tst_QBarSet::remove() | |
201 | { |
|
200 | { | |
202 | QCOMPARE(m_barset->count(), 0); |
|
201 | QCOMPARE(m_barset->count(), 0); | |
203 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
202 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
204 |
|
203 | |||
205 | m_barset->append(1.0); |
|
204 | m_barset->append(1.0); | |
206 | m_barset->append(2.0); |
|
205 | m_barset->append(2.0); | |
207 | m_barset->append(3.0); |
|
206 | m_barset->append(3.0); | |
208 | m_barset->append(4.0); |
|
207 | m_barset->append(4.0); | |
209 |
|
208 | |||
210 | QCOMPARE(m_barset->count(), 4); |
|
209 | QCOMPARE(m_barset->count(), 4); | |
211 | QCOMPARE(m_barset->sum(), 10.0); |
|
210 | QCOMPARE(m_barset->sum(), 10.0); | |
212 |
|
211 | |||
213 | m_barset->remove(2); // 1.0 2.0 4.0 |
|
212 | m_barset->remove(2); // 1.0 2.0 4.0 | |
214 | QCOMPARE(m_barset->at(0), 1.0); |
|
213 | QCOMPARE(m_barset->at(0), 1.0); | |
215 | QCOMPARE(m_barset->at(1), 2.0); |
|
214 | QCOMPARE(m_barset->at(1), 2.0); | |
216 | QCOMPARE(m_barset->at(2), 4.0); |
|
215 | QCOMPARE(m_barset->at(2), 4.0); | |
217 | QCOMPARE(m_barset->count(), 3); |
|
216 | QCOMPARE(m_barset->count(), 3); | |
218 | QCOMPARE(m_barset->sum(), 7.0); |
|
217 | QCOMPARE(m_barset->sum(), 7.0); | |
219 |
|
218 | |||
220 | m_barset->remove(0); // 2.0 4.0 |
|
219 | m_barset->remove(0); // 2.0 4.0 | |
221 | QCOMPARE(m_barset->at(0), 2.0); |
|
220 | QCOMPARE(m_barset->at(0), 2.0); | |
222 | QCOMPARE(m_barset->at(1), 4.0); |
|
221 | QCOMPARE(m_barset->at(1), 4.0); | |
223 | QCOMPARE(m_barset->count(), 2); |
|
222 | QCOMPARE(m_barset->count(), 2); | |
224 | QCOMPARE(m_barset->sum(), 6.0); |
|
223 | QCOMPARE(m_barset->sum(), 6.0); | |
225 | } |
|
224 | } | |
226 |
|
225 | |||
227 | void tst_QBarSet::replace_data() |
|
226 | void tst_QBarSet::replace_data() | |
228 | { |
|
227 | { | |
229 |
|
228 | |||
230 | } |
|
229 | } | |
231 |
|
230 | |||
232 | void tst_QBarSet::replace() |
|
231 | void tst_QBarSet::replace() | |
233 | { |
|
232 | { | |
234 | QCOMPARE(m_barset->count(), 0); |
|
233 | QCOMPARE(m_barset->count(), 0); | |
235 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
234 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
236 |
|
235 | |||
237 | m_barset->append(1.0); |
|
236 | m_barset->append(1.0); | |
238 | m_barset->append(2.0); |
|
237 | m_barset->append(2.0); | |
239 | m_barset->append(3.0); |
|
238 | m_barset->append(3.0); | |
240 | m_barset->append(4.0); |
|
239 | m_barset->append(4.0); | |
241 |
|
240 | |||
242 | QCOMPARE(m_barset->count(), 4); |
|
241 | QCOMPARE(m_barset->count(), 4); | |
243 | QCOMPARE(m_barset->sum(), 10.0); |
|
242 | QCOMPARE(m_barset->sum(), 10.0); | |
244 |
|
243 | |||
245 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 |
|
244 | m_barset->replace(0, 5.0); // 5.0 2.0 3.0 4.0 | |
246 | QCOMPARE(m_barset->count(), 4); |
|
245 | QCOMPARE(m_barset->count(), 4); | |
247 | QCOMPARE(m_barset->sum(), 14.0); |
|
246 | QCOMPARE(m_barset->sum(), 14.0); | |
248 | QCOMPARE(m_barset->at(0), 5.0); |
|
247 | QCOMPARE(m_barset->at(0), 5.0); | |
249 |
|
248 | |||
250 | m_barset->replace(3, 6.0); |
|
249 | m_barset->replace(3, 6.0); | |
251 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 |
|
250 | QCOMPARE(m_barset->count(), 4); // 5.0 2.0 3.0 6.0 | |
252 | QCOMPARE(m_barset->sum(), 16.0); |
|
251 | QCOMPARE(m_barset->sum(), 16.0); | |
253 | QCOMPARE(m_barset->at(0), 5.0); |
|
252 | QCOMPARE(m_barset->at(0), 5.0); | |
254 | QCOMPARE(m_barset->at(1), 2.0); |
|
253 | QCOMPARE(m_barset->at(1), 2.0); | |
255 | QCOMPARE(m_barset->at(2), 3.0); |
|
254 | QCOMPARE(m_barset->at(2), 3.0); | |
256 | QCOMPARE(m_barset->at(3), 6.0); |
|
255 | QCOMPARE(m_barset->at(3), 6.0); | |
257 | } |
|
256 | } | |
258 |
|
257 | |||
259 | void tst_QBarSet::at_data() |
|
258 | void tst_QBarSet::at_data() | |
260 | { |
|
259 | { | |
261 |
|
260 | |||
262 | } |
|
261 | } | |
263 |
|
262 | |||
264 | void tst_QBarSet::at() |
|
263 | void tst_QBarSet::at() | |
265 | { |
|
264 | { | |
266 | QCOMPARE(m_barset->count(), 0); |
|
265 | QCOMPARE(m_barset->count(), 0); | |
267 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
266 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
268 |
|
267 | |||
269 | m_barset->append(1.0); |
|
268 | m_barset->append(1.0); | |
270 | m_barset->append(2.0); |
|
269 | m_barset->append(2.0); | |
271 | m_barset->append(3.0); |
|
270 | m_barset->append(3.0); | |
272 | m_barset->append(4.0); |
|
271 | m_barset->append(4.0); | |
273 |
|
272 | |||
274 | QCOMPARE(m_barset->at(0), 1.0); |
|
273 | QCOMPARE(m_barset->at(0), 1.0); | |
275 | QCOMPARE(m_barset->at(1), 2.0); |
|
274 | QCOMPARE(m_barset->at(1), 2.0); | |
276 | QCOMPARE(m_barset->at(2), 3.0); |
|
275 | QCOMPARE(m_barset->at(2), 3.0); | |
277 | QCOMPARE(m_barset->at(3), 4.0); |
|
276 | QCOMPARE(m_barset->at(3), 4.0); | |
278 | } |
|
277 | } | |
279 |
|
278 | |||
280 | void tst_QBarSet::atOperator_data() |
|
279 | void tst_QBarSet::atOperator_data() | |
281 | { |
|
280 | { | |
282 |
|
281 | |||
283 | } |
|
282 | } | |
284 |
|
283 | |||
285 | void tst_QBarSet::atOperator() |
|
284 | void tst_QBarSet::atOperator() | |
286 | { |
|
285 | { | |
287 | QCOMPARE(m_barset->count(), 0); |
|
286 | QCOMPARE(m_barset->count(), 0); | |
288 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
287 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
289 |
|
288 | |||
290 | m_barset->append(1.0); |
|
289 | m_barset->append(1.0); | |
291 | m_barset->append(2.0); |
|
290 | m_barset->append(2.0); | |
292 | m_barset->append(3.0); |
|
291 | m_barset->append(3.0); | |
293 | m_barset->append(4.0); |
|
292 | m_barset->append(4.0); | |
294 |
|
293 | |||
295 | QCOMPARE(m_barset->operator [](0), 1.0); |
|
294 | QCOMPARE(m_barset->operator [](0), 1.0); | |
296 | QCOMPARE(m_barset->operator [](1), 2.0); |
|
295 | QCOMPARE(m_barset->operator [](1), 2.0); | |
297 | QCOMPARE(m_barset->operator [](2), 3.0); |
|
296 | QCOMPARE(m_barset->operator [](2), 3.0); | |
298 | QCOMPARE(m_barset->operator [](3), 4.0); |
|
297 | QCOMPARE(m_barset->operator [](3), 4.0); | |
299 | } |
|
298 | } | |
300 |
|
299 | |||
301 | void tst_QBarSet::count_data() |
|
300 | void tst_QBarSet::count_data() | |
302 | { |
|
301 | { | |
303 |
|
302 | |||
304 | } |
|
303 | } | |
305 |
|
304 | |||
306 | void tst_QBarSet::count() |
|
305 | void tst_QBarSet::count() | |
307 | { |
|
306 | { | |
308 | QCOMPARE(m_barset->count(), 0); |
|
307 | QCOMPARE(m_barset->count(), 0); | |
309 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
308 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
310 |
|
309 | |||
311 | m_barset->append(1.0); |
|
310 | m_barset->append(1.0); | |
312 | QCOMPARE(m_barset->count(),1); |
|
311 | QCOMPARE(m_barset->count(),1); | |
313 | m_barset->append(2.0); |
|
312 | m_barset->append(2.0); | |
314 | QCOMPARE(m_barset->count(),2); |
|
313 | QCOMPARE(m_barset->count(),2); | |
315 | m_barset->append(3.0); |
|
314 | m_barset->append(3.0); | |
316 | QCOMPARE(m_barset->count(),3); |
|
315 | QCOMPARE(m_barset->count(),3); | |
317 | m_barset->append(4.0); |
|
316 | m_barset->append(4.0); | |
318 | QCOMPARE(m_barset->count(),4); |
|
317 | QCOMPARE(m_barset->count(),4); | |
319 | } |
|
318 | } | |
320 |
|
319 | |||
321 | void tst_QBarSet::sum_data() |
|
320 | void tst_QBarSet::sum_data() | |
322 | { |
|
321 | { | |
323 |
|
322 | |||
324 | } |
|
323 | } | |
325 |
|
324 | |||
326 | void tst_QBarSet::sum() |
|
325 | void tst_QBarSet::sum() | |
327 | { |
|
326 | { | |
328 | QCOMPARE(m_barset->count(), 0); |
|
327 | QCOMPARE(m_barset->count(), 0); | |
329 | QVERIFY(qFuzzyIsNull(m_barset->sum())); |
|
328 | QVERIFY(qFuzzyIsNull(m_barset->sum())); | |
330 |
|
329 | |||
331 | m_barset->append(1.0); |
|
330 | m_barset->append(1.0); | |
332 |
Q |
|
331 | QVERIFY(qFuzzyCompare(m_barset->sum(),1.0)); | |
333 | m_barset->append(2.0); |
|
332 | m_barset->append(2.0); | |
334 |
Q |
|
333 | QVERIFY(qFuzzyCompare(m_barset->sum(),3.0)); | |
335 | m_barset->append(3.0); |
|
334 | m_barset->append(3.0); | |
336 |
Q |
|
335 | QVERIFY(qFuzzyCompare(m_barset->sum(),6.0)); | |
337 | m_barset->append(4.0); |
|
336 | m_barset->append(4.0); | |
338 |
Q |
|
337 | QVERIFY(qFuzzyCompare(m_barset->sum(),10.0)); | |
339 | } |
|
338 | } | |
340 |
|
339 | |||
341 |
|
||||
342 | QTEST_MAIN(tst_QBarSet) |
|
340 | QTEST_MAIN(tst_QBarSet) | |
343 |
|
341 | |||
344 | #include "tst_qbarset.moc" |
|
342 | #include "tst_qbarset.moc" | |
345 |
|
343 |
General Comments 0
You need to be logged in to leave comments.
Login now