summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qrect/tst_qrect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/tools/qrect/tst_qrect.cpp')
-rw-r--r--tests/auto/corelib/tools/qrect/tst_qrect.cpp228
1 files changed, 136 insertions, 92 deletions
diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp
index 1c2221ec29..0f3dd1a0ef 100644
--- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp
+++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp
@@ -1,37 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtTest/QtTest>
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
#include <qrect.h>
#include <qmargins.h>
#include <limits.h>
#include <qdebug.h>
+#include <array>
class tst_QRect : public QObject
{
@@ -124,6 +100,9 @@ private slots:
void margins();
void marginsf();
+ void toRectF_data();
+ void toRectF();
+
void translate_data();
void translate();
@@ -164,14 +143,17 @@ private slots:
void intersectsRectF();
void containsRect_data();
void containsRect();
+ void containsRectNormalized();
void containsRectF_data();
void containsRectF();
void containsPoint_data();
void containsPoint();
+ void containsPointNormalized();
void containsPointF_data();
void containsPointF();
void smallRects() const;
void toRect();
+ void span();
};
// Used to work around some floating point precision problems.
@@ -372,17 +354,20 @@ void tst_QRect::normalized_data()
QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect )
<< getQRectCase( LargestCoordQRect ); // overflow
QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << QRect( 100, 200, 11, 16 );
- QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << QRect(QPoint(-10,-10),QPoint(1,1));
+ QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << QRect(-9, -9, 10, 10);
QTest::newRow( "NegativePointQRect" ) << getQRectCase( NegativePointQRect ) << QRect( -10, -10, 5, 5 );
QTest::newRow( "NullQRect" ) << getQRectCase( NullQRect ) << getQRectCase( NullQRect );
QTest::newRow( "EmptyQRect" ) << getQRectCase( EmptyQRect ) << getQRectCase( EmptyQRect );
QTest::newRow( "ZeroWidth" ) << QRect(100, 200, 100, 0) << QRect(100, 200, 100, 0);
+ QTest::newRow( "ZeroHeight" ) << QRect(100, 200, 0, 100) << QRect(100, 200, 0, 100);
// Since "NegativeSizeQRect passes, I expect both of these to pass too.
// This passes, since height() returns -1 before normalization
- QTest::newRow( "NegativeHeight") << QRect(QPoint(100,201), QPoint(199,199)) << QRect(QPoint(100,199), QPoint(199,201));
+ QTest::newRow( "NegativeWidth") << QRect(QPoint(200,100), QSize(-1,100)) << QRect(QPoint(199,100), QSize(1,100));
+ QTest::newRow( "NegativeHeight") << QRect(QPoint(100,200), QSize(100,-1)) << QRect(QPoint(100,199), QSize(100,1));
+ QTest::newRow( "NegativeWidth2") << QRect(QPoint(200,100), QPoint(198,199)) << QRect(QPoint(199,100), QPoint(199,199));
// This, on the other hand height() returns 0 before normalization.
- QTest::newRow( "ZeroHeight1" ) << QRect(QPoint(100,200), QPoint(199,199)) << QRect(QPoint(100,199), QPoint(199,200));
- QTest::newRow( "ZeroHeight2" ) << QRect(QPoint(263,113), QPoint(136,112)) << QRect(QPoint(136,113), QPoint(263,112));
+ QTest::newRow( "ZeroHeight1" ) << QRect(QPoint(100,200), QPoint(199,199)) << QRect(QPoint(100,200), QPoint(199,199));
+ QTest::newRow( "ZeroHeight2" ) << QRect(QPoint(263,113), QPoint(136,112)) << QRect(QPoint(137,113), QPoint(262,112));
}
void tst_QRect::normalized()
@@ -390,7 +375,6 @@ void tst_QRect::normalized()
QFETCH(QRect, r);
QFETCH(QRect, nr);
- QEXPECT_FAIL("ZeroHeight1", "due to broken QRect definition (not possible to change, see QTBUG-22934)", Continue);
QCOMPARE(r.normalized(), nr);
}
@@ -478,6 +462,9 @@ void tst_QRect::right()
if (isLarge(r.width()))
return;
+ // width overflow
+ if (r.left() < r.right() && r.width() < 0)
+ return;
QCOMPARE(QRectF(r).right(), qreal(right+1));
}
@@ -510,6 +497,9 @@ void tst_QRect::bottom()
if (isLarge(r.height()))
return;
+ // height overflow
+ if (r.top() < r.bottom() && r.height() < 0)
+ return;
QCOMPARE(QRectF(r).bottom(), qreal(bottom + 1));
}
@@ -2515,16 +2505,11 @@ void tst_QRect::newMoveLeft_data()
{
// QTest::newRow( "LargestCoordQRect_MinimumInt" ) -- Not tested as it would cause an overflow
- QTest::newRow( "LargestCoordQRect_MiddleNegativeInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MiddleNegativeInt )
- << QRect( QPoint( INT_MIN/2, INT_MIN ), QPoint(INT_MIN/2-1, INT_MAX ) );
- QTest::newRow( "LargestCoordQRect_ZeroInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( ZeroInt )
- << QRect( QPoint( 0, INT_MIN ), QPoint(-1, INT_MAX ) );
- QTest::newRow( "LargestCoordQRect_MiddlePositiveInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MiddlePositiveInt )
- << QRect( QPoint( INT_MAX/2, INT_MIN ), QPoint(INT_MAX/2-1, INT_MAX ) );
- QTest::newRow( "LargestCoordQRect_MaximumInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MaximumInt )
- << QRect( QPoint( INT_MAX, INT_MIN ), QPoint(INT_MAX-1, INT_MAX ) );
- QTest::newRow( "LargestCoordQRect_RandomInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( RandomInt )
- << QRect( QPoint( 4953, INT_MIN ), QPoint(4952, INT_MAX ) );
+ // QTest::newRow( "LargestCoordQRect_MiddleNegativeInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_ZeroInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_MiddlePositiveInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_MaximumInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_RandomInt" ) -- Not tested as it would cause an overflow
}
{
@@ -2684,16 +2669,11 @@ void tst_QRect::newMoveTop_data()
{
// QTest::newRow( "LargestCoordQRect_MinimumInt" ) -- Not tested as it would cause an overflow
- QTest::newRow( "LargestCoordQRect_MiddleNegativeInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MiddleNegativeInt )
- << QRect( QPoint(INT_MIN,INT_MIN/2), QPoint(INT_MAX,INT_MIN/2-1) );
- QTest::newRow( "LargestCoordQRect_ZeroInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( ZeroInt )
- << QRect( QPoint(INT_MIN,0), QPoint(INT_MAX,-1) );
- QTest::newRow( "LargestCoordQRect_MiddlePositiveInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MiddlePositiveInt )
- << QRect( QPoint(INT_MIN,INT_MAX/2), QPoint(INT_MAX,INT_MAX/2-1) );
- QTest::newRow( "LargestCoordQRect_MaximumInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( MaximumInt )
- << QRect( QPoint(INT_MIN,INT_MAX), QPoint(INT_MAX,INT_MAX-1) );
- QTest::newRow( "LargestCoordQRect_RandomInt" ) << getQRectCase( LargestCoordQRect ) << getIntCase( RandomInt )
- << QRect( QPoint(INT_MIN,4953), QPoint(INT_MAX,4952) );
+ // QTest::newRow( "LargestCoordQRect_MiddleNegativeInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_ZeroInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_MiddlePositiveInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_MaximumInt" ) -- Not tested as it would cause an overflow
+ // QTest::newRow( "LargestCoordQRect_RandomInt" ) -- Not tested as it would cause an overflow
}
{
@@ -3525,6 +3505,39 @@ void tst_QRect::marginsf()
QCOMPARE(a, rectangle.marginsRemoved(margins));
}
+void tst_QRect::toRectF_data()
+{
+ QTest::addColumn<QRect>("input");
+ QTest::addColumn<QRectF>("result");
+
+ auto row = [](int x1, int y1, int w, int h) {
+ // QRectF -> QRect conversion tries to maintain size(), not bottomRight(),
+ // so compare in (topLeft(), size()) space
+ QTest::addRow("((%d, %d) (%dx%d))", x1, y1, w, h)
+ << QRect({x1, y1}, QSize{w, h}) << QRectF(QPointF(x1, y1), QSizeF(w, h));
+ };
+ constexpr std::array samples = {-1, 0, 1};
+ for (int x1 : samples) {
+ for (int y1 : samples) {
+ for (int w : samples) {
+ for (int h : samples) {
+ row(x1, y1, w, h);
+ }
+ }
+ }
+ }
+}
+
+void tst_QRect::toRectF()
+{
+ QFETCH(const QRect, input);
+ QFETCH(const QRectF, result);
+
+ QCOMPARE(result.toRect(), input); // consistency check
+ QCOMPARE(input.toRectF(), result);
+}
+
+
void tst_QRect::translate_data()
{
QTest::addColumn<QRect>("r");
@@ -3931,15 +3944,15 @@ void tst_QRect::intersectedRect_data()
QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << QRect(2, 2, 8, 8);
QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << QRect();
- QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << QRect(2, 2, 6, 6);
- QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << QRect(0, 0, 10, 10);
- QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << QRect(2, 2, 8, 8);
- QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << QRect();
+ QTest::newRow("test 05") << QRect(10, 10, -10, -10) << QRect( 2, 2, 6, 6) << QRect(2, 2, 6, 6);
+ QTest::newRow("test 06") << QRect(10, 10, -10, -10) << QRect( 0, 0, 10, 10) << QRect(0, 0, 10, 10);
+ QTest::newRow("test 07") << QRect(10, 10, -10, -10) << QRect( 2, 2, 10, 10) << QRect(2, 2, 8, 8);
+ QTest::newRow("test 08") << QRect(10, 10, -10, -10) << QRect(20, 20, 10, 10) << QRect();
- QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << QRect(2, 2, 6, 6);
- QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << QRect(0, 0, 10, 10);
- QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << QRect(2, 2, 8, 8);
- QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << QRect();
+ QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 6, 6, -4, -4) << QRect(2, 2, 4, 4);
+ QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect(10, 10, -10, -10) << QRect(0, 0, 10, 10);
+ QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(12, 12, -10, -10) << QRect(2, 2, 8, 8);
+ QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(30, 30, -10, -10) << QRect();
QTest::newRow("test 13") << QRect(0, 0, 10, 10) << QRect() << QRect();
QTest::newRow("test 14") << QRect() << QRect(0, 0, 10, 10) << QRect();
@@ -4016,15 +4029,15 @@ void tst_QRect::unitedRect_data()
QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << QRect(0, 0, 12, 12);
QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << QRect(0, 0, 30, 30);
- QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << QRect(0, 0, 10, 10);
- QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << QRect(0, 0, 10, 10);
- QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << QRect(0, 0, 12, 12);
- QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << QRect(0, 0, 30, 30);
+ QTest::newRow("test 05") << QRect(10, 10, -10, -10) << QRect( 2, 2, 6, 6) << QRect(0, 0, 10, 10);
+ QTest::newRow("test 06") << QRect(10, 10, -10, -10) << QRect( 0, 0, 10, 10) << QRect(0, 0, 10, 10);
+ QTest::newRow("test 07") << QRect(10, 10, -10, -10) << QRect( 2, 2, 10, 10) << QRect(0, 0, 12, 12);
+ QTest::newRow("test 08") << QRect(10, 10, -10, -10) << QRect(20, 20, 10, 10) << QRect(0, 0, 30, 30);
QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << QRect(0, 0, 10, 10);
QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << QRect(0, 0, 10, 10);
- QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(11, 11, -8, -8) << QRect(0, 0, 12, 12);
- QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(29, 29, -8, -8) << QRect(0, 0, 30, 30);
+ QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QRect(12, 12, -8, -8) << QRect(0, 0, 12, 12);
+ QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QRect(30, 30, -8, -8) << QRect(0, 0, 30, 30);
QTest::newRow("test 13") << QRect() << QRect(10, 10, 10, 10) << QRect(10, 10, 10, 10);
QTest::newRow("test 14") << QRect(10, 10, 10, 10) << QRect() << QRect(10, 10, 10, 10);
@@ -4166,10 +4179,10 @@ void tst_QRect::containsRect_data()
QTest::newRow("test 03") << QRect(0, 0, 10, 10) << QRect( 2, 2, 10, 10) << false;
QTest::newRow("test 04") << QRect(0, 0, 10, 10) << QRect(20, 20, 10, 10) << false;
- QTest::newRow("test 05") << QRect(9, 9, -8, -8) << QRect( 2, 2, 6, 6) << true;
- QTest::newRow("test 06") << QRect(9, 9, -8, -8) << QRect( 0, 0, 10, 10) << true;
- QTest::newRow("test 07") << QRect(9, 9, -8, -8) << QRect( 2, 2, 10, 10) << false;
- QTest::newRow("test 08") << QRect(9, 9, -8, -8) << QRect(20, 20, 10, 10) << false;
+ QTest::newRow("test 05") << QRect(9, 9, -9, -9) << QRect( 2, 2, 6, 6) << true;
+ QTest::newRow("test 06") << QRect(9, 9, -9, -9) << QRect( 0, 0, 9, 9) << true;
+ QTest::newRow("test 07") << QRect(9, 9, -9, -9) << QRect( 2, 2, 9, 9) << false;
+ QTest::newRow("test 08") << QRect(9, 9, -9, -9) << QRect(20, 20, 10, 10) << false;
QTest::newRow("test 09") << QRect(0, 0, 10, 10) << QRect( 7, 7, -4, -4) << true;
QTest::newRow("test 10") << QRect(0, 0, 10, 10) << QRect( 9, 9, -8, -8) << true;
@@ -4190,6 +4203,18 @@ void tst_QRect::containsRect()
QVERIFY(rect1.contains(rect2) == contains);
}
+void tst_QRect::containsRectNormalized()
+{
+ QRect rect(QPoint(10, 10), QPoint(0,0));
+ QRect normalized = rect.normalized();
+ for (int i = -2 ; i < 12; ++i) {
+ for (int j = -2 ; j < 12; ++j) {
+ for (int k = -2 ; k <= 2; ++k)
+ QCOMPARE(rect.contains(QRect(i,j,k,k)), normalized.contains(QRect(i,j,k,k)));
+ }
+ }
+}
+
void tst_QRect::containsRectF_data()
{
QTest::addColumn<QRectF>("rect1");
@@ -4245,18 +4270,18 @@ void tst_QRect::containsPoint_data()
QTest::newRow("test 11") << QRect(0, 0, 10, 10) << QPoint( 1, 8) << true << true;
QTest::newRow("test 12") << QRect(0, 0, 10, 10) << QPoint( 8, 8) << true << true;
- QTest::newRow("test 13") << QRect(9, 9, -8, -8) << QPoint( 0, 0) << true << false;
- QTest::newRow("test 14") << QRect(9, 9, -8, -8) << QPoint( 0, 10) << false << false;
- QTest::newRow("test 15") << QRect(9, 9, -8, -8) << QPoint(10, 0) << false << false;
- QTest::newRow("test 16") << QRect(9, 9, -8, -8) << QPoint(10, 10) << false << false;
- QTest::newRow("test 17") << QRect(9, 9, -8, -8) << QPoint( 0, 9) << true << false;
- QTest::newRow("test 18") << QRect(9, 9, -8, -8) << QPoint( 9, 0) << true << false;
- QTest::newRow("test 19") << QRect(9, 9, -8, -8) << QPoint( 9, 9) << true << false;
- QTest::newRow("test 20") << QRect(9, 9, -8, -8) << QPoint( 1, 0) << true << false;
- QTest::newRow("test 21") << QRect(9, 9, -8, -8) << QPoint( 9, 1) << true << false;
- QTest::newRow("test 22") << QRect(9, 9, -8, -8) << QPoint( 1, 1) << true << true;
- QTest::newRow("test 23") << QRect(9, 9, -8, -8) << QPoint( 1, 8) << true << true;
- QTest::newRow("test 24") << QRect(9, 9, -8, -8) << QPoint( 8, 8) << true << true;
+ QTest::newRow("test 13") << QRect(9, 9, -9, -9) << QPoint( 0, 0) << true << false;
+ QTest::newRow("test 14") << QRect(9, 9, -9, -9) << QPoint( 0, 9) << false << false;
+ QTest::newRow("test 15") << QRect(9, 9, -9, -9) << QPoint( 9, 0) << false << false;
+ QTest::newRow("test 16") << QRect(9, 9, -9, -9) << QPoint( 9, 9) << false << false;
+ QTest::newRow("test 17") << QRect(9, 9, -9, -9) << QPoint( 0, 8) << true << false;
+ QTest::newRow("test 18") << QRect(9, 9, -9, -9) << QPoint( 8, 0) << true << false;
+ QTest::newRow("test 19") << QRect(9, 9, -9, -9) << QPoint( 8, 8) << true << false;
+ QTest::newRow("test 20") << QRect(9, 9, -9, -9) << QPoint( 1, 0) << true << false;
+ QTest::newRow("test 21") << QRect(9, 9, -9, -9) << QPoint( 8, 1) << true << false;
+ QTest::newRow("test 22") << QRect(9, 9, -9, -9) << QPoint( 1, 1) << true << true;
+ QTest::newRow("test 23") << QRect(9, 9, -9, -9) << QPoint( 1, 7) << true << true;
+ QTest::newRow("test 24") << QRect(9, 9, -9, -9) << QPoint( 7, 7) << true << true;
QTest::newRow("test 25") << QRect(-1, 1, 10, 10) << QPoint() << false << false;
QTest::newRow("test 26") << QRect() << QPoint(1, 1) << false << false;
@@ -4274,14 +4299,22 @@ void tst_QRect::containsPoint()
QVERIFY(rect.contains(point, true) == containsProper);
}
+void tst_QRect::containsPointNormalized()
+{
+ QRect rect(QPoint(10, 10), QPoint(0,0));
+ QRect normalized = rect.normalized();
+ for (int i = 0 ; i < 10; ++i) {
+ for (int j = 0 ; j < 10; ++j)
+ QCOMPARE(rect.contains(QPoint(i,j)), normalized.contains(QPoint(i,j)));
+ }
+}
+
void tst_QRect::containsPointF_data()
{
QTest::addColumn<QRectF>("rect");
QTest::addColumn<QPointF>("point");
QTest::addColumn<bool>("contains");
- QTest::newRow("test 27") << QRectF() << QPointF() << false;
-
QTest::newRow("test 01") << QRectF(0, 0, 10, 10) << QPointF( 0, 0) << true;
QTest::newRow("test 02") << QRectF(0, 0, 10, 10) << QPointF( 0, 10) << true;
QTest::newRow("test 03") << QRectF(0, 0, 10, 10) << QPointF(10, 0) << true;
@@ -4340,12 +4373,12 @@ void tst_QRect::toRect()
for (qreal h = 1.0; h < 2.0; h += 0.25) {
const QRectF rectf(x, y, w, h);
const QRectF rect = rectf.toRect();
- QVERIFY(qAbs(rect.x() - rectf.x()) < 1.0);
- QVERIFY(qAbs(rect.y() - rectf.y()) < 1.0);
- QVERIFY(qAbs(rect.width() - rectf.width()) < 1.0);
- QVERIFY(qAbs(rect.height() - rectf.height()) < 1.0);
- QVERIFY(qAbs(rect.right() - rectf.right()) < 1.0);
- QVERIFY(qAbs(rect.bottom() - rectf.bottom()) < 1.0);
+ QVERIFY(qAbs(rect.x() - rectf.x()) <= 0.75);
+ QVERIFY(qAbs(rect.y() - rectf.y()) <= 0.75);
+ QVERIFY(qAbs(rect.width() - rectf.width()) <= 0.75);
+ QVERIFY(qAbs(rect.height() - rectf.height()) <= 0.75);
+ QVERIFY(qAbs(rect.right() - rectf.right()) <= 0.75);
+ QVERIFY(qAbs(rect.bottom() - rectf.bottom()) <= 0.75);
const QRectF arect = rectf.toAlignedRect();
QVERIFY(qAbs(arect.x() - rectf.x()) < 1.0);
@@ -4363,5 +4396,16 @@ void tst_QRect::toRect()
}
}
+void tst_QRect::span()
+{
+ QCOMPARE(QRect::span(QPoint( 0, 1), QPoint(9, 10)), QRect(QPoint(0, 1), QPoint( 9, 10)));
+
+ QCOMPARE(QRect::span(QPoint(10, 9), QPoint(1, 0)), QRect(QPoint(1, 0), QPoint(10, 9)));
+
+ QCOMPARE(QRect::span(QPoint(10, 1), QPoint(0, 9)), QRect(QPoint(0, 1), QPoint(10, 9)));
+
+ QCOMPARE(QRect::span(QPoint( 1, 10), QPoint(9, 0)), QRect(QPoint(1, 0), QPoint( 9, 10)));
+}
+
QTEST_MAIN(tst_QRect)
#include "tst_qrect.moc"