QString: unittests: clean-up creating a QChar[]
Pick-to: 6.5 Change-Id: I3864d145c05ae4268fe576f84723acc5eba3c2cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
b9b7f44563
commit
fdf112fd1d
|
|
@ -3185,14 +3185,16 @@ void tst_QString::append_data(DataOptions options)
|
|||
void tst_QString::append_special_cases()
|
||||
{
|
||||
{
|
||||
static constexpr char16_t utf16[] = u"Hello, World!";
|
||||
constexpr int len = std::char_traits<char16_t>::length(utf16);
|
||||
const auto *unicode = reinterpret_cast<const QChar *>(utf16);
|
||||
QString a;
|
||||
static const QChar unicode[] = { u'H', u'e', u'l', u'l', u'o', u',', u' ', u'W', u'o', u'r', u'l', u'd', u'!' };
|
||||
a.append(unicode, sizeof unicode / sizeof *unicode);
|
||||
a.append(unicode, len);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!"));
|
||||
static const QChar nl(u'\n');
|
||||
a.append(&nl, 1);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!\n"));
|
||||
a.append(unicode, sizeof unicode / sizeof *unicode);
|
||||
a.append(unicode, len);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
|
||||
a.append(unicode, 0); // no-op
|
||||
QCOMPARE(a, QLatin1String("Hello, World!\nHello, World!"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue