diff options
author | Matt Broadstone <mbroadstone@devonit.com> | 2014-01-04 16:59:32 -0600 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-16 21:49:26 +0100 |
commit | d6d7624796471b8296fdfa6492b0570bd78e1d93 (patch) | |
tree | a009e8b669d0ed4cc86128fa67a7f9211a5f7434 /tests/auto/corelib/json/tst_qtjson.cpp | |
parent | 13806e6787502f55754660c6241b31d41e6d9ac7 (diff) |
Added constructor to QJsonValue for const char *
For convenience, it reads more easily (and is somewhat expected) to
be able to add a string to a QJsonArray like you might with a
QVariantList: QJsonArray() << "string". Previously, QJsonValue provided
a private void* ctor to explicitly deny this case because it would
implicitly convert to a boolean. This ctor provides a const char* ctor
(much like QVariant) that interprets the incoming text as utf8 and
creates a String type QJsonValue.
[ChangeLog][QtCore][QJsonValue] Added constructor to QJsonValue for const char *
Change-Id: Icafa954d3da1fb264f9d0fd7cd1a1d2fbbe15095
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'tests/auto/corelib/json/tst_qtjson.cpp')
-rw-r--r-- | tests/auto/corelib/json/tst_qtjson.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 45ce836cbf..2312922a58 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -2242,6 +2242,14 @@ void tst_QtJson::valueEquals() QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(true)); QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(1.)); QVERIFY(QJsonValue(QJsonObject()) != QJsonValue(QJsonArray())); + + QVERIFY(QJsonValue("foo") == QJsonValue(QLatin1String("foo"))); + QVERIFY(QJsonValue("foo") == QJsonValue(QString("foo"))); + QVERIFY(QJsonValue("\x66\x6f\x6f") == QJsonValue(QString("foo"))); + QVERIFY(QJsonValue("\x62\x61\x72") == QJsonValue("bar")); + QVERIFY(QJsonValue(UNICODE_NON_CHARACTER) == QJsonValue(QString(UNICODE_NON_CHARACTER))); + QVERIFY(QJsonValue(UNICODE_DJE) == QJsonValue(QString(UNICODE_DJE))); + QVERIFY(QJsonValue("\xc3\xa9") == QJsonValue(QString("\xc3\xa9"))); } void tst_QtJson::bom() |