5#include <QFontDatabase>
6#include <QtCore/qatomicscopedvaluerollback.h>
8#include <initializer_list>
10using namespace Qt::StringLiterals;
31 void defaultTryTimeout();
37 using namespace std::chrono_literals;
40 QTest::defaultTryTimeout.store(1s, std::memory_order_relaxed);
61QVERIFY2(QFileInfo(
"file.txt").exists(),
"file.txt does not exist.");
65QCOMPARE(QString(
"hello").toUpper(), QString(
"HELLO"));
72 QTest::addColumn<QString>(
"aString");
73 QTest::addColumn<
int>(
"expected");
75 QTest::newRow(
"positive+value") <<
"42" << 42;
76 QTest::newRow(
"negative-value") <<
"-42" << -42;
77 QTest::newRow(
"zero") <<
"0" << 0;
84 QFETCH(QString, aString);
85 QFETCH(
int, expected);
87 QCOMPARE(aString.toInt(), expected);
97 QFAIL(
"This test has not been ported to this platform yet.");
101QFETCH(QString, myString);
102QCOMPARE(QString(
"hello").toUpper(), myString);
106QTEST(QString(
"hello").toUpper(),
"myString");
110if (!QSqlDatabase::drivers().contains(
"SQLITE"))
111 QSKIP(
"This test requires the SQLITE database driver");
115QEXPECT_FAIL(
"",
"Will fix in the next release", Continue);
121QEXPECT_FAIL(
"data27",
"Oh my, this is soooo broken", Abort);
127QTEST_MAIN(TestQString)
132 class MyTestObject :
public QObject
145QTest::ignoreMessage(QtWarningMsg,
"QDir::mkdir: Empty or null file name(s)");
153 QTest::addColumn<QString>(
"aString");
154 QTest::newRow(
"just.hello") << QString(
"hello");
155 QTest::newRow(
"a.null.string") << QString();
162 QTest::addColumn<
int>(
"input");
163 QTest::addColumn<QString>(
"output");
164 QTest::addRow(
"%d", 0) << 0 << QString(
"0");
165 QTest::addRow(
"%d", 1) << 1 << QString(
"1");
172 QTest::addColumn<
int>(
"intval");
173 QTest::addColumn<QString>(
"str");
174 QTest::addColumn<
double>(
"dbl");
175 QTest::newRow(
"row1") << 1 <<
"hello" << 1.5;
182 if (qstrcmp(QTest::currentTestFunction(),
"myDatabaseTest") == 0) {
192using namespace std::chrono_literals;
200 QString str1 = u"This is a test string"_s;
201 QString str2 = u"This is a test string"_s;
202 QCOMPARE(str1.localeAwareCompare(str2), 0);
204 str1.localeAwareCompare(str2);
213bool opened = file.open(QIODevice::WriteOnly);
217QVERIFY2(file.open(QIODevice::WriteOnly),
218 qPrintable(QString(
"open %1: %2")
219 .arg(file.fileName()).arg(file.errorString())));
226 const int expected[] = {8, 10, 12, 16, 20, 24};
227 QCOMPARE(QFontDatabase::standardSizes(), expected);
234 #define ARG(...) __VA_ARGS__
235 QCOMPARE(QFontDatabase::standardSizes(),
ARG({8, 10, 12, 16, 20, 24}));
243const auto restoreDefaultLocale = qScopeGuard([prior = QLocale()]() {
244 QLocale::setDefault(prior);
247QLocale::setDefault(QLocale::c());
252 using namespace std::chrono_literals;
255 const auto timeoutRollback = QAtomicScopedValueRollback(
256 QTest::defaultTryTimeout, 1s, std::memory_order_relaxed);
261 QCOMPARE(QTest::defaultTryTimeout.load(std::memory_order_relaxed), 1s);
void addSingleStringRows()
[20]
void addMultStringRows()
[20]
void wrapInFunction()
[16]
void compareListToInitializerList()
void quarterSecondSleep()
[22]
void compareListToArray()
void withRestoredDefaultLocale()