summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp')
-rw-r--r--tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp52
1 files changed, 43 insertions, 9 deletions
diff --git a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
index 481d7d7cfe..301a915dd6 100644
--- a/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
+++ b/tests/auto/network/kernel/qdnslookup/tst_qdnslookup.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2012 Jeremy Lainé <jeremy.laine@m4x.org>
-** Contact: http://www.qt-project.org/legal
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -170,10 +170,43 @@ void tst_QDnsLookup::lookup_data()
QTest::newRow("txt-empty") << int(QDnsLookup::TXT) << "" << int(QDnsLookup::InvalidRequestError) << "" << "" << "" << "" << "" << "" << "";
QTest::newRow("txt-notfound") << int(QDnsLookup::TXT) << "invalid.invalid" << int(QDnsLookup::NotFoundError) << "" << "" << "" << "" << "" << "" << "";
QTest::newRow("txt-single") << int(QDnsLookup::TXT) << "txt-single" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello";
- QTest::newRow("txt-multi-onerr") << int(QDnsLookup::TXT) << "txt-multi-onerr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello World";
+ QTest::newRow("txt-multi-onerr") << int(QDnsLookup::TXT) << "txt-multi-onerr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << ""
+ << QString::fromLatin1("Hello\0World", sizeof("Hello\0World") - 1);
QTest::newRow("txt-multi-multirr") << int(QDnsLookup::TXT) << "txt-multi-multirr" << int(QDnsLookup::NoError) << "" << "" << "" << "" << "" << "" << "Hello;World";
}
+static QByteArray msgDnsLookup(QDnsLookup::Error actualError,
+ int expectedError,
+ const QString &domain,
+ const QString &cname,
+ const QString &host,
+ const QString &srv,
+ const QString &mx,
+ const QString &ns,
+ const QString &ptr,
+ const QString &errorString)
+{
+ QString result;
+ QTextStream str(&result);
+ str << "Actual error: " << actualError;
+ if (!errorString.isEmpty())
+ str << " (" << errorString << ')';
+ str << ", expected: " << expectedError;
+ str << ", domain: " << domain;
+ if (!cname.isEmpty())
+ str << ", cname: " << cname;
+ str << ", host: " << host;
+ if (!srv.isEmpty())
+ str << " server: " << srv;
+ if (!mx.isEmpty())
+ str << " mx: " << mx;
+ if (!ns.isEmpty())
+ str << " ns: " << ns;
+ if (!ptr.isEmpty())
+ str << " ptr: " << ptr;
+ return result.toLocal8Bit();
+}
+
void tst_QDnsLookup::lookup()
{
QFETCH(int, type);
@@ -210,7 +243,8 @@ void tst_QDnsLookup::lookup()
QEXPECT_FAIL("", "Not yet supported on Android", Abort);
#endif
- QVERIFY2(int(lookup.error()) == error, qPrintable(lookup.errorString()));
+ QVERIFY2(int(lookup.error()) == error,
+ msgDnsLookup(lookup.error(), error, domain, cname, host, srv, mx, ns, ptr, lookup.errorString()));
if (error == QDnsLookup::NoError)
QVERIFY(lookup.errorString().isEmpty());
QCOMPARE(int(lookup.type()), type);
@@ -286,7 +320,7 @@ void tst_QDnsLookup::lookup()
QString text;
foreach (const QByteArray &ba, record.values()) {
if (!text.isEmpty())
- text += ' ';
+ text += '\0';
text += QString::fromLatin1(ba);
}
texts << text;