2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2020-11-26 16:31:50 +00:00
|
|
|
#include <QTest>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
//! [0]
|
|
|
|
class TestQString: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void toUpper_data();
|
|
|
|
void toUpper();
|
|
|
|
};
|
|
|
|
//! [0]
|
|
|
|
|
|
|
|
//! [1]
|
|
|
|
void TestQString::toUpper_data()
|
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("string");
|
|
|
|
QTest::addColumn<QString>("result");
|
|
|
|
|
2022-07-27 17:02:59 +00:00
|
|
|
QTest::newRow("all-lower") << "hello" << "HELLO";
|
2011-04-27 10:05:43 +00:00
|
|
|
QTest::newRow("mixed") << "Hello" << "HELLO";
|
2022-07-27 17:02:59 +00:00
|
|
|
QTest::newRow("all-upper") << "HELLO" << "HELLO";
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
//! [1]
|
|
|
|
|
|
|
|
//! [2]
|
|
|
|
void TestQString::toUpper()
|
|
|
|
{
|
|
|
|
QFETCH(QString, string);
|
|
|
|
QFETCH(QString, result);
|
|
|
|
|
|
|
|
QCOMPARE(string.toUpper(), result);
|
|
|
|
}
|
|
|
|
//! [2]
|
|
|
|
|
|
|
|
//! [3]
|
|
|
|
QTEST_MAIN(TestQString)
|
|
|
|
#include "testqstring.moc"
|
|
|
|
//! [3]
|
|
|
|
|