diff options
Diffstat (limited to 'tests/auto/corelib/tools/qsize/tst_qsize.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qsize/tst_qsize.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qsize/tst_qsize.cpp b/tests/auto/corelib/tools/qsize/tst_qsize.cpp index 83b4f1bd34..80dc4ebaee 100644 --- a/tests/auto/corelib/tools/qsize/tst_qsize.cpp +++ b/tests/auto/corelib/tools/qsize/tst_qsize.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -29,6 +29,8 @@ #include <QTest> #include <qsize.h> +#include <array> + Q_DECLARE_METATYPE(QMargins) class tst_QSize : public QObject @@ -47,6 +49,9 @@ private slots: void grownOrShrunkBy_data(); void grownOrShrunkBy(); + void toSizeF_data(); + void toSizeF(); + void transpose_data(); void transpose(); @@ -232,6 +237,30 @@ void tst_QSize::grownOrShrunkBy() QCOMPARE(shrunk.grownBy(margins), input); } +void tst_QSize::toSizeF_data() +{ + QTest::addColumn<QSize>("input"); + QTest::addColumn<QSizeF>("result"); + + auto row = [](int w, int h) { + QTest::addRow("(%d, %d)", w, h) << QSize(w, h) << QSizeF(w, h); + }; + constexpr std::array samples = {-1, 0, 1}; + for (int w : samples) { + for (int h : samples) { + row(w, h); + } + } +} + +void tst_QSize::toSizeF() +{ + QFETCH(const QSize, input); + QFETCH(const QSizeF, result); + + QCOMPARE(input.toSizeF(), result); +} + void tst_QSize::transpose_data() { QTest::addColumn<QSize>("input1"); |