28 #include <QStringList>
39 void section_regexp_data() { section_data_impl(); }
40 void section_regularexpression_data() { section_data_impl(); }
41 void section_regularexpression() { section_impl<QRegularExpression>(); }
42 void section_string_data() { section_data_impl(
false); }
43 void section_string() { section_impl<QString>(); }
49 void toCaseFolded_data();
52 void number_qlonglong_data();
53 void number_qlonglong() { number_impl<qlonglong>(); }
54 void number_qulonglong_data();
55 void number_qulonglong() { number_impl<qulonglong>(); }
57 void number_double_data();
61 void section_data_impl(
bool includeRegExOnly =
true);
62 template <
typename RX>
void section_impl();
63 template <
typename Integer>
void number_impl();
70 void tst_QString::section_data_impl(
bool includeRegExOnly)
72 QTest::addColumn<QString>(
"s");
73 QTest::addColumn<QString>(
"sep");
74 QTest::addColumn<bool>(
"isRegExp");
78 if (includeRegExOnly) {
84 template <
typename RX>
92 template <
typename RX>
99 template <
typename RX>
100 void tst_QString::section_impl()
106 RX
rx(isRegExp ? sep : escape<RX>(sep));
108 for (
int i = 0;
i < 20; ++
i)
117 void tst_QString::toUpper_data()
119 QTest::addColumn<QString>(
"s");
129 for (
int i = 0;
i < 300 /
pattern.size(); ++
i)
137 for (
int i = 0;
i < 300 /
pattern.size(); ++
i)
146 QTest::newRow(
"300<a>+300<A>") << (lowerLatin1 + upperLatin1);
147 QTest::newRow(
"300<A>+300<a>") << (upperLatin1 + lowerLatin1);
149 QTest::newRow(
"300<10428>") << (lowerDeseret + lowerDeseret);
150 QTest::newRow(
"300<10400>") << (upperDeseret + upperDeseret);
152 QTest::newRow(
"150<10428>+150<10400>") << (lowerDeseret + upperDeseret);
153 QTest::newRow(
"150<10400>+150<10428>") << (upperDeseret + lowerDeseret);
155 QTest::newRow(
"300a+150<10400>") << (lowerLatin1 + upperDeseret);
156 QTest::newRow(
"300a+150<10428>") << (lowerLatin1 + lowerDeseret);
157 QTest::newRow(
"300A+150<10400>") << (upperLatin1 + upperDeseret);
158 QTest::newRow(
"300A+150<10428>") << (upperLatin1 + lowerDeseret);
163 void tst_QString::toUpper()
168 [[maybe_unused]]
auto r =
s.toUpper();
172 void tst_QString::toLower_data()
177 void tst_QString::toLower()
182 [[maybe_unused]]
auto r =
s.toLower();
186 void tst_QString::toCaseFolded_data()
191 void tst_QString::toCaseFolded()
196 [[maybe_unused]]
auto r =
s.toCaseFolded();
200 template <
typename Integer>
201 void tst_QString::number_impl()
214 template <
typename Integer>
226 void tst_QString::number_qlonglong_data()
228 QTest::addColumn<qlonglong>(
"number");
229 QTest::addColumn<int>(
"base");
230 QTest::addColumn<QString>(
"expected");
232 number_integer_common<qlonglong>();
242 << std::numeric_limits<qlonglong>::max() << 10 <<
QStringLiteral(
"9223372036854775807");
244 << std::numeric_limits<qlonglong>::min() << 10
247 << std::numeric_limits<qlonglong>::max() << 2 <<
QString(63,
u'1');
248 QTest::newRow(
"qlonglong-min, base 2") << std::numeric_limits<qlonglong>::min() << 2
251 << std::numeric_limits<qlonglong>::max() << 16 << (
QChar(
u'7') +
QString(15,
u'f'));
252 QTest::newRow(
"qlonglong-min, base 16") << std::numeric_limits<qlonglong>::min() << 16
256 void tst_QString::number_qulonglong_data()
258 QTest::addColumn<qulonglong>(
"number");
259 QTest::addColumn<int>(
"base");
260 QTest::addColumn<QString>(
"expected");
262 number_integer_common<qulonglong>();
265 << (
qulonglong(std::numeric_limits<qlonglong>::max()) + 1) << 10
268 << std::numeric_limits<qulonglong>::max() << 10
271 << std::numeric_limits<qulonglong>::max() << 2 <<
QString(64,
u'1');
273 << std::numeric_limits<qulonglong>::max() << 16 <<
QString(16,
u'f');
276 void tst_QString::number_double_data()
278 QTest::addColumn<double>(
"number");
279 QTest::addColumn<char>(
"format");
280 QTest::addColumn<int>(
"precision");
281 QTest::addColumn<QString>(
"expected");
301 for (
auto &datum :
data) {
302 QTest::addRow(
"%s, format '%c', precision %d", qPrintable(datum.expected), datum.f,
304 << datum.d << datum.f << datum.p << datum.expected;
308 void tst_QString::number_double()
324 #include "tst_bench_qstring.moc"
small capitals from c petite p scientific f u
small capitals from c petite p scientific i
[1]
The QChar class provides a 16-bit Unicode character.
static constexpr char16_t highSurrogate(char32_t ucs4) noexcept
static constexpr char16_t lowSurrogate(char32_t ucs4) noexcept
The QObject class is the base class of all Qt objects.
The QRegularExpression class provides pattern matching using regular expressions.
The QString class provides a Unicode character string.
QString section(QChar sep, qsizetype start, qsizetype end=-1, SectionFlags flags=SectionDefault) const
static QString number(int, int base=10)
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Q_TESTLIB_EXPORT QTestData & addRow(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei GLsizei GLenum format
GLenum GLint GLint * precision
#define QStringLiteral(str)
#define QTEST_APPLESS_MAIN(TestObject)
#define QFETCH(Type, name)
void number_integer_common()
QString escape(const QString &s)
QString escape< QString >(const QString &s)