QString: unittests: clean-up creating a QChar[]
Change-Id: I3864d145c05ae4268fe576f84723acc5eba3c2cb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit fdf112fd1d023e16cc862d47c789d46a62e56b08)
This commit is contained in:
parent
c7375ed4c2
commit
1ff2debb68
@ -3020,14 +3020,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[] = { 'H', 'e', 'l', 'l', 'o', ',', ' ', 'W', 'o', 'r', 'l', 'd', '!' };
|
||||
a.append(unicode, sizeof unicode / sizeof *unicode);
|
||||
a.append(unicode, len);
|
||||
QCOMPARE(a, QLatin1String("Hello, World!"));
|
||||
static const QChar nl('\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…
x
Reference in New Issue
Block a user