tst_QString: refactor one test
By using a lambda and QTest::ThrowOnFailEnabler; this required changing the custom QCOMPARE in those tests. Drive-by, use the UTF16 character instead of the hexdecimal representation, one of them is easier to read. Change-Id: Ic319cc2afdda6a73e293ebf16eb4f8df469b6d72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
68f970d285
commit
d3d395ab3d
@ -5936,11 +5936,11 @@ void tst_QString::setRawData()
|
|||||||
|
|
||||||
void tst_QString::setUnicode()
|
void tst_QString::setUnicode()
|
||||||
{
|
{
|
||||||
const QChar ptr[] = { QChar(0x1234), QChar(0x0000) };
|
const QChar ptr[] = { u'ሴ', QChar(0x0000) };
|
||||||
|
|
||||||
QString str;
|
QTest::ThrowOnFailEnabler throwOnFail;
|
||||||
QVERIFY(!str.isDetached());
|
|
||||||
str.setUnicode(ptr, 1);
|
auto doTest = [](const auto ptr, QString &str) mutable {
|
||||||
// make sure that the data is copied
|
// make sure that the data is copied
|
||||||
QVERIFY(str.constData() != ptr);
|
QVERIFY(str.constData() != ptr);
|
||||||
QVERIFY(str.isDetached());
|
QVERIFY(str.isDetached());
|
||||||
@ -5952,6 +5952,14 @@ void tst_QString::setUnicode()
|
|||||||
str.setUnicode(nullptr, 1);
|
str.setUnicode(nullptr, 1);
|
||||||
QCOMPARE(str.size(), 1);
|
QCOMPARE(str.size(), 1);
|
||||||
QCOMPARE(str, u"t");
|
QCOMPARE(str, u"t");
|
||||||
|
};
|
||||||
|
|
||||||
|
{
|
||||||
|
QString str;
|
||||||
|
QVERIFY(!str.isDetached());
|
||||||
|
str.setUnicode(ptr, 1);
|
||||||
|
doTest(ptr, str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QString::fromStdString()
|
void tst_QString::fromStdString()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user