diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-03-31 12:00:13 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-04-01 06:26:42 +0200 |
commit | e848dd14f5ece82bae0d4b0d1acc268701174321 (patch) | |
tree | d075e2d8bb1c4a69ba9d1033efb2d2052397d92a | |
parent | 7822b89aef30404164bc6f6f790d0cc563e10cbf (diff) | |
download | qtbase-e848dd14f5ece82bae0d4b0d1acc268701174321.tar.gz |
tst_qxmlstream: add non-US-ASCII hasAttribute() checks
One each of L1 and non-L1.
Will help porting that API to QAnyStringView.
Pick-to: 6.5
Change-Id: I51afc07c5b2384409c2627164e95265265fbb544
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index a91a9bc752..52025f7e23 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -1255,8 +1255,20 @@ void tst_QXmlStream::hasAttributeSignature() const void tst_QXmlStream::hasAttribute() const { - QXmlStreamReader reader(QLatin1String("<e xmlns:p='http://example.com/2' xmlns='http://example.com/' " - "attr1='value' attr2='value2' p:attr3='value3' emptyAttr=''><noAttributes/></e>")); + auto xml = QStringLiteral("<e" + " xmlns:p='http://example.com/2'" + " xmlns='http://example.com/'" + " attr1='value'" + " attr2='value2'" + " p:attr3='value3'" + " emptyAttr=''" + " atträbute='meep'" + " α='β'" + " >" + " <noAttributes/>" + "</e>"); + + QXmlStreamReader reader(xml); QCOMPARE(reader.readNext(), QXmlStreamReader::StartDocument); QCOMPARE(reader.readNext(), QXmlStreamReader::StartElement); @@ -1267,6 +1279,8 @@ void tst_QXmlStream::hasAttribute() const QVERIFY(atts.hasAttribute(QLatin1String("attr2"))); QVERIFY(atts.hasAttribute(QLatin1String("p:attr3"))); QVERIFY(atts.hasAttribute(QLatin1String("emptyAttr"))); + QVERIFY(atts.hasAttribute(QLatin1String("attr\xE4""bute"))); + // α is not representable in L1... QVERIFY(!atts.hasAttribute(QLatin1String("DOESNOTEXIST"))); /* Test with an empty & null namespaces. */ @@ -1277,6 +1291,8 @@ void tst_QXmlStream::hasAttribute() const QVERIFY(atts.hasAttribute(QString::fromLatin1("attr1"))); QVERIFY(atts.hasAttribute(QString::fromLatin1("attr2"))); QVERIFY(atts.hasAttribute(QString::fromLatin1("p:attr3"))); + QVERIFY(atts.hasAttribute(QStringLiteral("atträbute"))); + QVERIFY(atts.hasAttribute(QStringLiteral("α"))); QVERIFY(atts.hasAttribute(QString::fromLatin1("emptyAttr"))); QVERIFY(!atts.hasAttribute(QString::fromLatin1("DOESNOTEXIST"))); @@ -1290,6 +1306,7 @@ void tst_QXmlStream::hasAttribute() const QVERIFY(!atts.hasAttribute(QLatin1String("WRONG_NAMESPACE"), QString::fromLatin1("attr3"))); /* Invoke on an QXmlStreamAttributes that has no attributes at all. */ + QCOMPARE(reader.readNext(), QXmlStreamReader::Characters); QCOMPARE(reader.readNext(), QXmlStreamReader::StartElement); const QXmlStreamAttributes &atts2 = reader.attributes(); |