From 2523dbee725453a20698020d6ae63f7446489891 2012-11-07 13:33:41 From: Marek Rosa Date: 2012-11-07 13:33:41 Subject: [PATCH] Replaced qFuzzyIsNull with qFuzzyCompare. Once qchart test case still uses qFuzzyIsNull becasue it started failing when qFuzzyCompare was used --- diff --git a/demos/piechartcustomization/pentool.cpp b/demos/piechartcustomization/pentool.cpp index 2298831..5844b7b 100644 --- a/demos/piechartcustomization/pentool.cpp +++ b/demos/piechartcustomization/pentool.cpp @@ -106,7 +106,7 @@ void PenTool::showColorDialog() void PenTool::updateWidth(double width) { - if (!qFuzzyIsNull(width - m_pen.widthF())) { + if (!qFuzzyCompare(width, m_pen.widthF())) { m_pen.setWidthF(width); emit changed(); } diff --git a/src/axis/chartaxis.cpp b/src/axis/chartaxis.cpp index 5429052..f6a44f9 100644 --- a/src/axis/chartaxis.cpp +++ b/src/axis/chartaxis.cpp @@ -276,7 +276,7 @@ void ChartAxis::setLabelPadding(int padding) bool ChartAxis::isEmpty() { - return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyIsNull(m_min - m_max); + return m_axisRect.isEmpty() || m_gridRect.isEmpty() || qFuzzyCompare(m_min, m_max); } void ChartAxis::handleDomainUpdated() @@ -293,7 +293,7 @@ void ChartAxis::handleDomainUpdated() max = domain->maxY(); } - if (!qFuzzyIsNull(m_min - min) || !qFuzzyIsNull(m_max - max)) { + if (!qFuzzyCompare(m_min, min) || !qFuzzyCompare(m_max, max)) { m_min = min; m_max = max; diff --git a/src/axis/valueaxis/qvalueaxis.cpp b/src/axis/valueaxis/qvalueaxis.cpp index 4d5e916..ffbaf30 100644 --- a/src/axis/valueaxis/qvalueaxis.cpp +++ b/src/axis/valueaxis/qvalueaxis.cpp @@ -219,13 +219,13 @@ void QValueAxis::setRange(qreal min, qreal max) setTickCount(ticks); } - if (!qFuzzyIsNull(d->m_min - min)) { + if (!qFuzzyCompare(d->m_min, min)) { d->m_min = min; changed = true; emit minChanged(min); } - if (!qFuzzyIsNull(d->m_max - max)) { + if (!qFuzzyCompare(d->m_max, max)) { d->m_max = max; changed = true; emit maxChanged(max); @@ -264,7 +264,7 @@ void QValueAxis::setNiceNumbersEnabled(bool enable) Q_D(QValueAxis); if (d->m_niceNumbers != enable) { d->m_niceNumbers = enable; - if (enable && !qFuzzyIsNull(d->m_max - d->m_min)) + if (enable && !qFuzzyCompare(d->m_max, d->m_min)) setRange(d->m_min, d->m_max); } } diff --git a/src/barchart/horizontal/bar/horizontalbarchartitem.cpp b/src/barchart/horizontal/bar/horizontalbarchartitem.cpp index a0ad4db..c2361cb 100644 --- a/src/barchart/horizontal/bar/horizontalbarchartitem.cpp +++ b/src/barchart/horizontal/bar/horizontalbarchartitem.cpp @@ -67,14 +67,14 @@ QVector HorizontalBarChartItem::calculateLayout() layout.append(rect); bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(barSet->value(category))) + if (!qFuzzyCompare(barSet->value(category), 0)) label->setText(QString::number(barSet->value(category))); else label->setText(QString("")); diff --git a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp index c66112a..9263c40 100644 --- a/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp +++ b/src/barchart/horizontal/percent/horizontalpercentbarchartitem.cpp @@ -65,14 +65,14 @@ QVector HorizontalPercentBarChartItem::calculateLayout() layout.append(rect); bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(m_series->d_func()->valueAt(set, category))) { + if (!qFuzzyCompare(m_series->d_func()->valueAt(set, category), 0)) { int p = m_series->d_func()->percentageAt(set, category) * 100; QString vString(QString::number(p)); vString.truncate(3); diff --git a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp index b1dc7f5..b43d652 100644 --- a/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp +++ b/src/barchart/horizontal/stacked/horizontalstackedbarchartitem.cpp @@ -62,14 +62,14 @@ QVector HorizontalStackedBarChartItem::calculateLayout() bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(barSet->value(category))) + if (!qFuzzyCompare(barSet->value(category), 0)) label->setText(QString::number(barSet->value(category))); else label->setText(QString("")); diff --git a/src/barchart/qabstractbarseries.cpp b/src/barchart/qabstractbarseries.cpp index 518c2e2..2f92686 100644 --- a/src/barchart/qabstractbarseries.cpp +++ b/src/barchart/qabstractbarseries.cpp @@ -484,7 +484,7 @@ qreal QAbstractBarSeriesPrivate::percentageAt(int set, int category) qreal value = m_barSets.at(set)->at(category); qreal sum = categorySum(category); - if (qFuzzyIsNull(sum)) + if (qFuzzyCompare(sum, 0)) return 0; return value / sum; diff --git a/src/barchart/vertical/bar/barchartitem.cpp b/src/barchart/vertical/bar/barchartitem.cpp index 2210821..8ee5b3d 100644 --- a/src/barchart/vertical/bar/barchartitem.cpp +++ b/src/barchart/vertical/bar/barchartitem.cpp @@ -66,14 +66,14 @@ QVector BarChartItem::calculateLayout() layout.append(rect); bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(barSet->value(category))) + if (!qFuzzyCompare(barSet->value(category), 0)) label->setText(QString::number(barSet->value(category))); else label->setText(QString("")); diff --git a/src/barchart/vertical/percent/percentbarchartitem.cpp b/src/barchart/vertical/percent/percentbarchartitem.cpp index 3b5bcb7..3ba34a0 100644 --- a/src/barchart/vertical/percent/percentbarchartitem.cpp +++ b/src/barchart/vertical/percent/percentbarchartitem.cpp @@ -63,7 +63,7 @@ QVector PercentBarChartItem::calculateLayout() Bar *bar = m_bars.at(itemIndex); bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); @@ -73,7 +73,7 @@ QVector PercentBarChartItem::calculateLayout() QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(m_series->d_func()->valueAt(set, category))) { + if (!qFuzzyCompare(m_series->d_func()->valueAt(set, category), 0)) { int p = m_series->d_func()->percentageAt(set, category) * 100; QString vString(QString::number(p)); vString.truncate(3); diff --git a/src/barchart/vertical/stacked/stackedbarchartitem.cpp b/src/barchart/vertical/stacked/stackedbarchartitem.cpp index c39b216..548e8b2 100644 --- a/src/barchart/vertical/stacked/stackedbarchartitem.cpp +++ b/src/barchart/vertical/stacked/stackedbarchartitem.cpp @@ -61,14 +61,14 @@ QVector StackedBarChartItem::calculateLayout() Bar *bar = m_bars.at(itemIndex); bar->setPen(barSet->m_pen); bar->setBrush(barSet->m_brush); - if (qFuzzyIsNull(rectHeight)) + if (qFuzzyCompare(rectHeight, 0)) bar->setVisible(false); else bar->setVisible(barsVisible); QGraphicsSimpleTextItem *label = m_labels.at(itemIndex); - if (!qFuzzyIsNull(barSet->value(category))) + if (!qFuzzyCompare(barSet->value(category), 0)) label->setText(QString::number(barSet->value(category))); else label->setText(QString("")); diff --git a/src/chartbackground.cpp b/src/chartbackground.cpp index 7907429..fb33a25 100644 --- a/src/chartbackground.cpp +++ b/src/chartbackground.cpp @@ -83,7 +83,7 @@ void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *o int ChartBackground::roundness(qreal size) const { - if (qFuzzyIsNull(size)) + if (qFuzzyCompare(size, 0)) return 0; return 100 * m_diameter / int(size); } diff --git a/src/domain.cpp b/src/domain.cpp index 570cfc4..7847905 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -41,14 +41,14 @@ void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY) bool axisXChanged = false; bool axisYChanged = false; - if (!qFuzzyIsNull(m_minX - minX) || !qFuzzyIsNull(m_maxX - maxX)) { + if (!qFuzzyCompare(m_minX, minX) || !qFuzzyCompare(m_maxX, maxX)) { m_minX = minX; m_maxX = maxX; axisXChanged = true; emit rangeXChanged(m_minX, m_maxX); } - if (!qFuzzyIsNull(m_minY - minY) || !qFuzzyIsNull(m_maxY - maxY)) { + if (!qFuzzyCompare(m_minY, minY) || !qFuzzyCompare(m_maxY, maxY)) { m_minY = minY; m_maxY = maxY; axisYChanged = true; @@ -103,7 +103,7 @@ qreal Domain::spanY() const bool Domain::isEmpty() const { - return qFuzzyIsNull(spanX()) || qFuzzyIsNull(spanY()); + return qFuzzyCompare(spanX(), 0) || qFuzzyCompare(spanY(), 0); } void Domain::zoomIn(const QRectF &rect, const QSizeF &size) @@ -181,10 +181,10 @@ void Domain::handleAxisUpdated() bool QTCOMMERCIALCHART_AUTOTEST_EXPORT operator== (const Domain &domain1, const Domain &domain2) { - return (qFuzzyIsNull(domain1.m_maxX - domain2.m_maxX) && - qFuzzyIsNull(domain1.m_maxY - domain2.m_maxY) && - qFuzzyIsNull(domain1.m_minX - domain2.m_minX) && - qFuzzyIsNull(domain1.m_minY - domain2.m_minY)); + return (qFuzzyCompare(domain1.m_maxX, domain2.m_maxX) && + qFuzzyCompare(domain1.m_maxY, domain2.m_maxY) && + qFuzzyCompare(domain1.m_minX, domain2.m_minX) && + qFuzzyCompare(domain1.m_minY, domain2.m_minY)); } diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 7379cef..7c6f1b0 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -612,7 +612,7 @@ void QPieSeries::setHorizontalPosition(qreal relativePosition) if (relativePosition > 1.0) relativePosition = 1.0; - if (!qFuzzyIsNull(d->m_pieRelativeHorPos - relativePosition)) { + if (!qFuzzyCompare(d->m_pieRelativeHorPos, relativePosition)) { d->m_pieRelativeHorPos = relativePosition; emit d->horizontalPositionChanged(); } @@ -633,7 +633,7 @@ void QPieSeries::setVerticalPosition(qreal relativePosition) if (relativePosition > 1.0) relativePosition = 1.0; - if (!qFuzzyIsNull(d->m_pieRelativeVerPos - relativePosition)) { + if (!qFuzzyCompare(d->m_pieRelativeVerPos, relativePosition)) { d->m_pieRelativeVerPos = relativePosition; emit d->verticalPositionChanged(); } @@ -663,7 +663,7 @@ qreal QPieSeries::pieSize() const void QPieSeries::setPieStartAngle(qreal angle) { Q_D(QPieSeries); - if (qFuzzyIsNull(d->m_pieStartAngle - angle)) + if (qFuzzyCompare(d->m_pieStartAngle, angle)) return; d->m_pieStartAngle = angle; d->updateDerivativeData(); @@ -688,7 +688,7 @@ qreal QPieSeries::pieStartAngle() const void QPieSeries::setPieEndAngle(qreal angle) { Q_D(QPieSeries); - if (qFuzzyIsNull(d->m_pieEndAngle - angle)) + if (qFuzzyCompare(d->m_pieEndAngle, angle)) return; d->m_pieEndAngle = angle; d->updateDerivativeData(); @@ -764,13 +764,13 @@ void QPieSeriesPrivate::updateDerivativeData() foreach (QPieSlice *s, m_slices) sum += s->value(); - if (!qFuzzyIsNull(m_sum - sum)) { + if (!qFuzzyCompare(m_sum, sum)) { m_sum = sum; emit q_func()->sumChanged(); } // nothing to show.. - if (qFuzzyIsNull(m_sum)) + if (qFuzzyCompare(m_sum, 0)) return; // update slice attributes @@ -793,12 +793,12 @@ void QPieSeriesPrivate::setSizes(qreal innerSize, qreal outerSize) { bool changed = false; - if (!qFuzzyIsNull(m_holeRelativeSize - innerSize)) { + if (!qFuzzyCompare(m_holeRelativeSize, innerSize)) { m_holeRelativeSize = innerSize; changed = true; } - if (!qFuzzyIsNull(m_pieRelativeSize - outerSize)) { + if (!qFuzzyCompare(m_pieRelativeSize, outerSize)) { m_pieRelativeSize = outerSize; changed = true; } diff --git a/src/piechart/qpieslice.cpp b/src/piechart/qpieslice.cpp index c79886f..d0bc18c 100644 --- a/src/piechart/qpieslice.cpp +++ b/src/piechart/qpieslice.cpp @@ -480,7 +480,7 @@ QString QPieSlice::label() const void QPieSlice::setValue(qreal value) { value = qAbs(value); // negative values not allowed - if (!qFuzzyIsNull(d_ptr->m_data.m_value - value)) { + if (!qFuzzyCompare(d_ptr->m_data.m_value, value)) { d_ptr->m_data.m_value = value; emit valueChanged(); } @@ -629,7 +629,7 @@ QFont QPieSlice::labelFont() const void QPieSlice::setLabelArmLengthFactor(qreal factor) { - if (!qFuzzyIsNull(d_ptr->m_data.m_labelArmLengthFactor - factor)) { + if (!qFuzzyCompare(d_ptr->m_data.m_labelArmLengthFactor, factor)) { d_ptr->m_data.m_labelArmLengthFactor = factor; emit d_ptr->labelArmLengthFactorChanged(); } @@ -642,7 +642,7 @@ qreal QPieSlice::labelArmLengthFactor() const void QPieSlice::setExplodeDistanceFactor(qreal factor) { - if (!qFuzzyIsNull(d_ptr->m_data.m_explodeDistanceFactor - factor)) { + if (!qFuzzyCompare(d_ptr->m_data.m_explodeDistanceFactor, factor)) { d_ptr->m_data.m_explodeDistanceFactor = factor; emit d_ptr->explodeDistanceFactorChanged(); } @@ -754,7 +754,7 @@ void QPieSlicePrivate::setLabelFont(const QFont &font, bool themed) void QPieSlicePrivate::setPercentage(qreal percentage) { - if (!qFuzzyIsNull(m_data.m_percentage - percentage)) { + if (!qFuzzyCompare(m_data.m_percentage, percentage)) { m_data.m_percentage = percentage; emit q_ptr->percentageChanged(); } @@ -762,7 +762,7 @@ void QPieSlicePrivate::setPercentage(qreal percentage) void QPieSlicePrivate::setStartAngle(qreal angle) { - if (!qFuzzyIsNull(m_data.m_startAngle - angle)) { + if (!qFuzzyCompare(m_data.m_startAngle, angle)) { m_data.m_startAngle = angle; emit q_ptr->startAngleChanged(); } @@ -770,7 +770,7 @@ void QPieSlicePrivate::setStartAngle(qreal angle) void QPieSlicePrivate::setAngleSpan(qreal span) { - if (!qFuzzyIsNull(m_data.m_angleSpan - span)) { + if (!qFuzzyCompare(m_data.m_angleSpan, span)) { m_data.m_angleSpan = span; emit q_ptr->angleSpanChanged(); } diff --git a/src/qchart.cpp b/src/qchart.cpp index ca049ec..7c84d1d 100644 --- a/src/qchart.cpp +++ b/src/qchart.cpp @@ -286,7 +286,7 @@ void QChart::zoomOut() */ void QChart::zoom(qreal factor) { - if (qFuzzyIsNull(factor)) + if (qFuzzyCompare(factor, 0)) return; if (qFuzzyCompare(factor, (qreal)1.0)) diff --git a/src/scatterchart/qscatterseries.cpp b/src/scatterchart/qscatterseries.cpp index 2a6eb95..543541f 100644 --- a/src/scatterchart/qscatterseries.cpp +++ b/src/scatterchart/qscatterseries.cpp @@ -239,7 +239,7 @@ void QScatterSeries::setMarkerSize(qreal size) { Q_D(QScatterSeries); - if (!qFuzzyIsNull(d->m_size - size)) { + if (!qFuzzyCompare(d->m_size, size)) { d->m_size = size; emit d->updated(); } diff --git a/src/scroller.cpp b/src/scroller.cpp index f3fe824..99c7491 100644 --- a/src/scroller.cpp +++ b/src/scroller.cpp @@ -64,7 +64,7 @@ void Scroller::scrollTo(const QPointF &delta) // Release was quick enough. Start scrolling. qreal interval = 25; qreal time = m_timeStamp.msecsTo(QTime::currentTime()); - if (qFuzzyIsNull(time)) { + if (qFuzzyCompare(time, 0)) { m_speed = delta / 5; } else { m_speed = delta * interval / time; @@ -72,7 +72,7 @@ void Scroller::scrollTo(const QPointF &delta) qreal fraction = qMax(qAbs(m_speed.x()), qAbs(m_speed.y())); - if (!qFuzzyIsNull(fraction)) { + if (!qFuzzyCompare(fraction, 0)) { m_fraction.setX(qAbs(m_speed.x() / fraction)); m_fraction.setY(qAbs(m_speed.y() / fraction)); } else { diff --git a/src/xychart/xychart.cpp b/src/xychart/xychart.cpp index efc8950..d7d65f8 100644 --- a/src/xychart/xychart.cpp +++ b/src/xychart/xychart.cpp @@ -219,7 +219,7 @@ void XYChart::handleGeometryChanged(const QRectF &rect) bool XYChart::isEmpty() { - return !m_clipRect.isValid() || qFuzzyIsNull(m_maxX - m_minX) || qFuzzyIsNull(m_maxY - m_minY) || m_series->points().isEmpty(); + return !m_clipRect.isValid() || qFuzzyCompare(m_maxX, m_minX) || qFuzzyCompare(m_maxY, m_minY) || m_series->points().isEmpty(); } #include "moc_xychart_p.cpp" diff --git a/tests/auto/domain/tst_domain.cpp b/tests/auto/domain/tst_domain.cpp index e4cfbab..e4cd994 100644 --- a/tests/auto/domain/tst_domain.cpp +++ b/tests/auto/domain/tst_domain.cpp @@ -191,12 +191,12 @@ void tst_Domain::handleAxisUpdatedX() axis.m_max=max; axis.emitUpdated(); - QVERIFY(qFuzzyIsNull(domain.minX() - min)); - QVERIFY(qFuzzyIsNull(domain.maxX() - max)); + QVERIFY(qFuzzyCompare(domain.minX(), min)); + QVERIFY(qFuzzyCompare(domain.maxX(), max)); QList arg1 = spy1.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); + QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); + QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); TRY_COMPARE(spy0.count(), 1); TRY_COMPARE(spy1.count(), 1); @@ -230,12 +230,12 @@ void tst_Domain::handleAxisUpdatedY() axis.m_max = max; axis.emitUpdated(); - QVERIFY(qFuzzyIsNull(domain.minY() - min)); - QVERIFY(qFuzzyIsNull(domain.maxY() - max)); + QVERIFY(qFuzzyCompare(domain.minY(), min)); + QVERIFY(qFuzzyCompare(domain.maxY(), max)); QList arg1 = spy2.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); + QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); + QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); TRY_COMPARE(spy0.count(), 1); TRY_COMPARE(spy1.count(), 0); @@ -504,12 +504,12 @@ void tst_Domain::setRangeX() domain.setRangeX(min, max); - QVERIFY(qFuzzyIsNull(domain.minX() - min)); - QVERIFY(qFuzzyIsNull(domain.maxX() - max)); + QVERIFY(qFuzzyCompare(domain.minX(), min)); + QVERIFY(qFuzzyCompare(domain.maxX(), max)); QList arg1 = spy1.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); + QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); + QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); TRY_COMPARE(spy0.count(), 1); TRY_COMPARE(spy1.count(), 1); @@ -538,12 +538,12 @@ void tst_Domain::setRangeY() domain.setRangeY(min, max); - QVERIFY(qFuzzyIsNull(domain.minY() - min)); - QVERIFY(qFuzzyIsNull(domain.maxY() - max)); + QVERIFY(qFuzzyCompare(domain.minY(), min)); + QVERIFY(qFuzzyCompare(domain.maxY(), max)); QList arg1 = spy2.first(); - QVERIFY(qFuzzyIsNull(arg1.at(0).toReal() - min)); - QVERIFY(qFuzzyIsNull(arg1.at(1).toReal() - max)); + QVERIFY(qFuzzyCompare(arg1.at(0).toReal(), min)); + QVERIFY(qFuzzyCompare(arg1.at(1).toReal(), max)); TRY_COMPARE(spy0.count(), 1); TRY_COMPARE(spy1.count(), 0); diff --git a/tests/auto/qbarset/tst_qbarset.cpp b/tests/auto/qbarset/tst_qbarset.cpp index f470df3..b150eb4 100644 --- a/tests/auto/qbarset/tst_qbarset.cpp +++ b/tests/auto/qbarset/tst_qbarset.cpp @@ -93,7 +93,7 @@ void tst_QBarSet::qbarset() QBarSet barset(QString("label")); QCOMPARE(barset.label(), QString("label")); QCOMPARE(barset.count(), 0); - QVERIFY(qFuzzyIsNull(barset.sum())); + QVERIFY(qFuzzyCompare(barset.sum(), 0)); } void tst_QBarSet::label_data() @@ -129,7 +129,7 @@ void tst_QBarSet::append() QFETCH(int, count); QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QSignalSpy valueSpy(m_barset, SIGNAL(valuesAdded(int,int))); @@ -159,7 +159,7 @@ void tst_QBarSet::appendOperator() QFETCH(int, count); QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); @@ -185,7 +185,7 @@ void tst_QBarSet::insert_data() void tst_QBarSet::insert() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QSignalSpy valueSpy(m_barset,SIGNAL(valuesAdded(int,int))); m_barset->insert(0, 1.0); // 1.0 @@ -215,7 +215,7 @@ void tst_QBarSet::remove_data() void tst_QBarSet::remove() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QSignalSpy valueSpy(m_barset,SIGNAL(valuesRemoved(int,int))); @@ -275,7 +275,7 @@ void tst_QBarSet::remove() // Remove more items than list has m_barset->remove(0,312); QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QCOMPARE(valueSpy.count(), 1); valueSpyArg = valueSpy.takeFirst(); @@ -296,7 +296,7 @@ void tst_QBarSet::replace_data() void tst_QBarSet::replace() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); QSignalSpy valueSpy(m_barset,SIGNAL(valueChanged(int))); m_barset->append(1.0); @@ -347,7 +347,7 @@ void tst_QBarSet::at_data() void tst_QBarSet::at() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); m_barset->append(1.0); m_barset->append(2.0); @@ -368,7 +368,7 @@ void tst_QBarSet::atOperator_data() void tst_QBarSet::atOperator() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); m_barset->append(1.0); m_barset->append(2.0); @@ -389,7 +389,7 @@ void tst_QBarSet::count_data() void tst_QBarSet::count() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); m_barset->append(1.0); QCOMPARE(m_barset->count(),1); @@ -409,7 +409,7 @@ void tst_QBarSet::sum_data() void tst_QBarSet::sum() { QCOMPARE(m_barset->count(), 0); - QVERIFY(qFuzzyIsNull(m_barset->sum())); + QVERIFY(qFuzzyCompare(m_barset->sum(), 0)); m_barset->append(1.0); QVERIFY(qFuzzyCompare(m_barset->sum(), (qreal)1.0)); diff --git a/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp b/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp index cb0a67a..a6a0a4b 100644 --- a/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp +++ b/tests/auto/qcategoryaxis/tst_qcategoryaxis.cpp @@ -98,16 +98,16 @@ void tst_QCategoryAxis::qcategoryaxis() { qabstractaxis(); - QVERIFY(qFuzzyIsNull(m_categoryaxis->max())); - QVERIFY(qFuzzyIsNull(m_categoryaxis->min())); + QVERIFY(qFuzzyCompare(m_categoryaxis->max(), 0)); + QVERIFY(qFuzzyCompare(m_categoryaxis->min(), 0)); QCOMPARE(m_categoryaxis->type(), QAbstractAxis::AxisTypeCategory); m_chart->setAxisX(m_categoryaxis, m_series); m_view->show(); QTest::qWaitForWindowShown(m_view); - QVERIFY(!qFuzzyIsNull(m_categoryaxis->max())); - QVERIFY(!qFuzzyIsNull(m_categoryaxis->min())); + QVERIFY(!qFuzzyCompare(m_categoryaxis->max(), 0)); + QVERIFY(!qFuzzyCompare(m_categoryaxis->min(), 0)); } void tst_QCategoryAxis::max_raw_data() @@ -127,7 +127,7 @@ void tst_QCategoryAxis::max_raw() QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); m_categoryaxis->setMax(max); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->max() - max), "Not equal"); + QVERIFY2(qFuzzyCompare(m_categoryaxis->max(), max), "Not equal"); QCOMPARE(spy0.count(), 1); QCOMPARE(spy1.count(), 0); @@ -175,7 +175,7 @@ void tst_QCategoryAxis::min_raw() QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); m_categoryaxis->setMin(min); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->min() - min), "Not equal"); + QVERIFY2(qFuzzyCompare(m_categoryaxis->min(), min), "Not equal"); QCOMPARE(spy0.count(), 0); QCOMPARE(spy1.count(), 1); @@ -228,8 +228,8 @@ void tst_QCategoryAxis::range_raw() QSignalSpy spy2(m_categoryaxis, SIGNAL(rangeChanged(qreal,qreal))); m_categoryaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_categoryaxis->max() - max), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_categoryaxis->min(), min), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_categoryaxis->max(), max), "Max not equal"); QCOMPARE(spy0.count(), 1); QCOMPARE(spy1.count(), 1); diff --git a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp b/tests/auto/qvalueaxis/tst_qvalueaxis.cpp index 079c053..2030e86 100644 --- a/tests/auto/qvalueaxis/tst_qvalueaxis.cpp +++ b/tests/auto/qvalueaxis/tst_qvalueaxis.cpp @@ -102,8 +102,8 @@ void tst_QValueAxis::qvalueaxis() { qabstractaxis(); - QVERIFY(qFuzzyIsNull(m_valuesaxis->max())); - QVERIFY(qFuzzyIsNull(m_valuesaxis->min())); + QVERIFY(qFuzzyCompare(m_valuesaxis->max(), 0)); + QVERIFY(qFuzzyCompare(m_valuesaxis->min(), 0)); QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); QCOMPARE(m_valuesaxis->tickCount(), 5); QCOMPARE(m_valuesaxis->type(), QAbstractAxis::AxisTypeValue); @@ -112,8 +112,8 @@ void tst_QValueAxis::qvalueaxis() m_view->show(); QTest::qWaitForWindowShown(m_view); - QVERIFY(!qFuzzyIsNull(m_valuesaxis->max())); - QVERIFY(!qFuzzyIsNull(m_valuesaxis->min())); + QVERIFY(!qFuzzyCompare(m_valuesaxis->max(), 0)); + QVERIFY(!qFuzzyCompare(m_valuesaxis->min(), 0)); QCOMPARE(m_valuesaxis->niceNumbersEnabled(), false); QCOMPARE(m_valuesaxis->tickCount(), 5); } @@ -135,7 +135,7 @@ void tst_QValueAxis::max_raw() QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); m_valuesaxis->setMax(max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Not equal"); QCOMPARE(spy0.count(), 1); QCOMPARE(spy1.count(), 0); @@ -184,7 +184,7 @@ void tst_QValueAxis::min_raw() QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); m_valuesaxis->setMin(min); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Not equal"); QCOMPARE(spy0.count(), 0); QCOMPARE(spy1.count(), 1); @@ -245,8 +245,8 @@ void tst_QValueAxis::niceNumbersEnabled() m_valuesaxis->setRange(min, max); m_valuesaxis->setTickCount(ticks); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); QSignalSpy spy0(m_valuesaxis, SIGNAL(maxChanged(qreal))); QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); @@ -255,15 +255,15 @@ void tst_QValueAxis::niceNumbersEnabled() m_valuesaxis->setNiceNumbersEnabled(niceNumbersEnabled); QCOMPARE(m_valuesaxis->niceNumbersEnabled(), niceNumbersEnabled); - if(!qFuzzyIsNull(expectedMin - min)) + if(!qFuzzyCompare(expectedMin, min)) QCOMPARE(spy1.count(), 1); - if(!qFuzzyIsNull(expectedMax - max)) + if(!qFuzzyCompare(expectedMax, max)) QCOMPARE(spy0.count(), 1); - if((!qFuzzyIsNull(expectedMin - min)) || (!qFuzzyIsNull(expectedMax - max))) + if((!qFuzzyCompare(expectedMin, min)) || (!qFuzzyCompare(expectedMax, max))) QCOMPARE(spy2.count(), 1); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - expectedMin), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - expectedMax), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), expectedMin), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), expectedMax), "Max not equal"); QCOMPARE(m_valuesaxis->tickCount(), expectedTicks); } @@ -287,8 +287,8 @@ void tst_QValueAxis::range_raw() QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); m_valuesaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); QCOMPARE(spy0.count(), 1); QCOMPARE(spy1.count(), 1); @@ -371,8 +371,8 @@ void tst_QValueAxis::noautoscale() QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); m_valuesaxis->setRange(min, max); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); QCOMPARE(spy0.count(), 1); QCOMPARE(spy1.count(), 1); @@ -381,8 +381,8 @@ void tst_QValueAxis::noautoscale() m_chart->setAxisX(m_valuesaxis, m_series); m_view->show(); QTest::qWaitForWindowShown(m_view); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() - min), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - max), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), min), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), max), "Max not equal"); } void tst_QValueAxis::autoscale_data() @@ -396,8 +396,8 @@ void tst_QValueAxis::autoscale() QSignalSpy spy1(m_valuesaxis, SIGNAL(minChanged(qreal))); QSignalSpy spy2(m_valuesaxis, SIGNAL(rangeChanged(qreal,qreal))); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min()), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max()), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), 0), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), 0), "Max not equal"); m_chart->setAxisX(m_valuesaxis, m_series); QCOMPARE(spy0.count(), 1); @@ -406,8 +406,8 @@ void tst_QValueAxis::autoscale() m_view->show(); QTest::qWaitForWindowShown(m_view); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->min() + 100), "Min not equal"); - QVERIFY2(qFuzzyIsNull(m_valuesaxis->max() - 100), "Max not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->min(), -100), "Min not equal"); + QVERIFY2(qFuzzyCompare(m_valuesaxis->max(), 100), "Max not equal"); } QTEST_MAIN(tst_QValueAxis)