summaryrefslogtreecommitdiffstats
path: root/tests/auto/xml/sax
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/xml/sax')
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp17
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp11
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp14
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/xmldocs/not-wf/sa/142.xml.refbin309 -> 311 bytes
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/064.xml.refbin312 -> 316 bytes
-rw-r--r--tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.refbin381 -> 378 bytes
6 files changed, 15 insertions, 27 deletions
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp
index b5d9fea315..c5597c6f8e 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/main.cpp
@@ -37,7 +37,6 @@
#include "parser.h"
-static QTextStream qout(stdout, QIODevice::WriteOnly);
static QTextStream qerr(stderr, QIODevice::WriteOnly);
static void usage()
@@ -79,19 +78,15 @@ int main(int argc, const char *argv[])
if (out_file_name.isEmpty())
out_file_name = file_name + ".ref";
- QFile _out_file;
- QTextStream _out_stream;
- QTextStream *out_stream;
+ QFile out_file;
if (out_file_name == "-") {
- out_stream = &qout;
+ out_file.open(stdout, QFile::WriteOnly);
} else {
- _out_file.setFileName(out_file_name);
- if (!_out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
+ out_file.setFileName(out_file_name);
+ if (!out_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
qerr << "Could not open " << out_file_name << ": " << strerror(errno) << Qt::endl;
return 1;
}
- _out_stream.setDevice(&_out_file);
- out_stream = &_out_stream;
}
Parser parser;
@@ -102,9 +97,7 @@ int main(int argc, const char *argv[])
parser.parseFile(&in_file);
- out_stream->setCodec("utf8");
-
- *out_stream << parser.result();
+ out_file.write(parser.result().toUtf8());
return 0;
}
diff --git a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
index 44f8101955..24aa9376da 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/parser/parser.cpp
@@ -142,11 +142,12 @@ bool ContentHandler::startElement(const QString &namespaceURI,
QString ContentHandler::escapeStr(const QString &s)
{
QString result = s;
- result.replace(QRegularExpression("\""), "\\\"");
- result.replace(QRegularExpression("\\"), "\\\\");
- result.replace(QRegularExpression("\n"), "\\n");
- result.replace(QRegularExpression("\r"), "\\r");
- result.replace(QRegularExpression("\t"), "\\t");
+ result.replace(QChar(0), "\\0");
+ result.replace("\\", "\\\\");
+ result.replace("\"", "\\\"");
+ result.replace("\n", "\\n");
+ result.replace("\r", "\\r");
+ result.replace("\t", "\\t");
return result;
}
diff --git a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
index cea4e3c8b8..df158cae0f 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
+++ b/tests/auto/xml/sax/qxmlsimplereader/tst_qxmlsimplereader.cpp
@@ -311,14 +311,12 @@ void tst_QXmlSimpleReader::testGoodXmlFile()
QVERIFY(file.open(QIODevice::ReadOnly));
Parser parser;
- QEXPECT_FAIL(QFINDTESTDATA("xmldocs/valid/sa/089.xml").toLocal8Bit().constData(), "a form feed character is not accepted in XML", Continue);
QVERIFY(parser.parseFile(&file));
QFile ref_file(file_name + ".ref");
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
- QTextStream ref_stream(&ref_file);
- ref_stream.setCodec("UTF-8");
- QString ref_file_contents = ref_stream.readAll();
+ QByteArray data = ref_file.readAll();
+ QString ref_file_contents = QString::fromUtf8(data.constData(), data.size());
QCOMPARE(parser.result(), ref_file_contents);
}
@@ -393,9 +391,7 @@ void tst_QXmlSimpleReader::testBadXmlFile()
QFile ref_file(file_name + ".ref");
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
- QTextStream ref_stream(&ref_file);
- ref_stream.setCodec("UTF-8");
- QString ref_file_contents = ref_stream.readAll();
+ QString ref_file_contents = QString::fromUtf8(ref_file.readAll());
QEXPECT_FAIL(QFINDTESTDATA("xmldocs/not-wf/sa/145.xml").toLocal8Bit().constData(), "Surrogate code point 0xD800 should be rejected", Continue);
@@ -469,9 +465,7 @@ void tst_QXmlSimpleReader::testIncrementalParsing()
QFile ref_file(file_name + ".ref");
QVERIFY(ref_file.open(QIODevice::ReadOnly | QIODevice::Text));
- QTextStream ref_stream(&ref_file);
- ref_stream.setCodec("UTF-8");
- QString ref_file_contents = ref_stream.readAll();
+ QString ref_file_contents = QString::fromUtf8(ref_file.readAll());
QCOMPARE(parser.result(), ref_file_contents);
}
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/not-wf/sa/142.xml.ref b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/not-wf/sa/142.xml.ref
index 7ce4da6a06..0684cfa943 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/not-wf/sa/142.xml.ref
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/not-wf/sa/142.xml.ref
Binary files differ
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/064.xml.ref b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/064.xml.ref
index 579aeb52f6..0b806c96a8 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/064.xml.ref
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/064.xml.ref
Binary files differ
diff --git a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.ref b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.ref
index 7c68c32286..f09bc2bd09 100644
--- a/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.ref
+++ b/tests/auto/xml/sax/qxmlsimplereader/xmldocs/valid/sa/089.xml.ref
Binary files differ